|
| 26 Jul 2011 10:19 AM |
I'm using a function called getPlayer which should return a player, but it says that the character is nil. My code is as follows, and the error where kill is marked, but probably with all other commands as well. If you can help, thanks.
root=script.Parent player=game.Players.LocalPlayer
function getPlayer(name) plyrlist = {} found = 0 if string.lower(name) == "me" then return {player}
elseif string.lower(name) == "all" then return game.Players:GetPlayers()
elseif string.lower(name) == "others" then plyrs = game.Players:getChildren() for i = 1, #plyrs do if plyrs[i]:IsA("Player") and plyrs[i] ~= player then table.insert(plyrlist,plyrs[i]) end end return plyrlist else plyrs = game.Players:GetPlayers() for i = 1, #plyrs do if string.find(string.lower(plyrs[i].Name),string.lower(name)) == 1 then char = {plyrs[i]} found = found + 1 end end if found == 0 then return nil elseif found == 1 then return char elseif found > 1 then return nil end end end
----------------------------------------------------------------------BAN banned={} root.Ban.Ban.MouseButton1Down:connect(function() plr=root.Ban.Person
if getPlayer(plr.Text) then plr2=getPlayer(plr.Text) plr2:remove() table.insert(banned, plr2) end end)
game.Players.PlayerAdded:connect(function(p) for i, v in pairs(banned)do if p.Name:lower() == v:lower() then p:remove() end end end) ----------------------------------------------------------------------CLEAN root.Clean.Clean.MouseButton1Down:connect(function() player.Character.Torso.Anchored=true for i, v in pairs(Workspace:GetChildren())do if game.Players:FindFirstChild(v.Name) == nil and not v:IsA("Message") and not v:IsA("Camera") then v:remove() end end a=root.Clean.Clean.Base:clone() a.Parent=Workspace a.CFrame = CFrame.new(0, 0, 0) player.Character.Torso.Anchored=false end) ----------------------------------------------------------------------INSERT root.Insert.Insert.MouseButton1Down:connect(function() asset=root.Insert.id parent=root.Insert.parent
a=game:GetService("InsertService"):LoadAsset(asset.Text) if Workspace:FindFirstChild(parent.Text) then a.Parent=Workspace[parent.Text] else a.Parent=Workspace end a:MoveTo(player.Character.Head.Position - Vector3.new(10, 4, 10)) end) ----------------------------------------------------------------------KICK root.Kick.Kick.MouseButton1Down:connect(function() plr=root.Kick.Person
if getPlayer(plr.Text) then plr2=getPlayer(plr.Text) plr2:remove() end end) ----------------------------------------------------------------------KILL root.Kill.Kill.MouseButton1Down:connect(function() plr=root.Kill.Person
if getPlayer(plr.Text) then plr2=getPlayer(plr.Text) plr2.Character.Humanoid.Health=0 end end) ----------------------------------------------------------------------LUA root.Lua.Lua.MouseButton1Down:connect(function() lua=root.Lua.code Err=root.Parent.Err
worked, error = coroutine.resume(coroutine.create(function() loadstring(lua.Text)() end)) if not worked then Err.Text=error wait(5) Err.Text="Output" end end)
-My hand is a dolphin |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2011 10:31 AM |
Bump.
-My hand is a dolphin |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2011 10:34 AM |
| GetPlayer returns a table, and from what I could see from the first command I looked at (I think it was ban... you should use DP for that :D), you were trying to index the return value as an instance. Is that the cause of the problem? |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2011 10:36 AM |
Oh nuts, it's a table? I knew that. >.> Thanks.
Also, I don't want to use DP with it because... Things could get out of hand in a script builder. :O
-My hand is a dolphin |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2011 10:40 AM |
name="crazypotato4" print(name .. ", I have one thing to say..." .. string.rep("THANK YOU! ", 9001))
-My hand is a dolphin |
|
|
| Report Abuse |
|
|