|
| 25 Feb 2015 08:35 PM |
local function ff(plr) local ff = Instance.new("ForceField",plr.Character) end
says plr is a nil value
but...
elseif m:lower():sub(0,3) == "ff/" then local plr = game.Players:FindFirstChild(m:lower():sub(4)) ff(plr) |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2015 08:36 PM |
do this: print(m:lower():sub(4))
You'll see what's wrong |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2015 08:38 PM |
i don't see what's wrong?
20:37:07.097 - ServerScriptService.AdminScript:28: attempt to index local 'plr' (a nil value) 20:37:07.098 - Stack Begin 20:37:07.099 - Script 'ServerScriptService.AdminScript', Line 28 - upvalue ff 20:37:07.099 - Script 'ServerScriptService.AdminScript', Line 83 20:37:07.100 - Stack End |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2015 08:39 PM |
Put the print above the local plr = ...
(I'm pretty sure it should be :sub(3)) |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2015 08:40 PM |
Also. You might want to do this to avoid errors
if plr ~= nil then ff(plr) end |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2015 08:41 PM |
| To check if something is there, you don't have to do ~= nil. If you just put if plr then, that works too. |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2015 08:43 PM |
Now my unff command isn't working...
local function unff(plr) for _,v in next, plr.Character do if v:IsA("ForceField") then v:Destroy() end end end |
|
|
| Report Abuse |
|
|
ChoongJae
|
  |
| Joined: 10 Oct 2009 |
| Total Posts: 670 |
|
|
| 25 Feb 2015 08:51 PM |
for _,v in next, plr.Character do don't you mean
for _,v in next, plr.Character:GetChildren() do |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2015 08:55 PM |
for _,v in next, plr.Character do
This is actually new to me. what is the purpose of 'next' here? |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2015 08:56 PM |
http://lua-users.org/wiki/ForTutorial
Oh huh, that's super interesting |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2015 08:56 PM |
character = player.Character or player.CharacterAdded:wait()
^ Suggestion. Modify to needs. |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2015 08:57 PM |
To understand what exactly DiamondBladee is doing check this article: http://lua-users.org/wiki/TernaryOperator
It's called a ternary, bascially it's a compressed if satement |
|
|
| Report Abuse |
|
|
|
| 26 Feb 2015 08:09 AM |
| I know what that is lol, but thanks anyways. And yeah, I saw my careless mistake. |
|
|
| Report Abuse |
|
|