Your problem may be line 4; You did not code that line correctly; You did line 3 correctly, but not line 4, this is what is happening;
-Line 3
-Line 4
As you look carefully, there is a Space, when you call '/kill PlayerName', it is also adding the ' ' to the string because you did not code the sub correctly [String Manipulation], considering upping the sub number.
Now, let me explain to you the sub method;
local String = "I'm a String!"
print(String:sub(1,5))
print(String:sub(5))
Now, all we need to do now is fix your script, let's re-code it a bit to make it look a bit more clean; We are going to create a new function, and redo your command, for, your other will not work;
function PlrAdded(plr)
plr.Chatted:connect(function(msg)
if msg:lower():sub(1,6) == "/kill " then
local Plr = game.Players:FindFirstChild(msg:sub(7))
if Plr and Plr.Character then
Plr.Character:BreakJoints()
end
end
end)
end
game.Players.PlayerAdded:connect(PlrAdded)
for i,v in pairs(game.Players:GetPlayers()) do PlrAdded(v) end
Hope this helped, and sorry if I did not give a good explanation!
4 comments
It's msg:sub(7) to get the player you're looking for. Character 6 is a space, so you'd be trying to get a player with a space at the beginning of the name.
Don't just post code, explain your answer in English.
@Perci, This is the exact same code as asked in the question, He obviously dosent know how the edit button works, so he posted it here c;
Not the point.. The point is that it doesn't do ANYTHING!