The script is supposed to kill a player's Character, I've tried so many times to fix it but it still doesn't work, here is the script command;
if string.lower(string.sub(1,5),msg)=="kill/" findplayer=game:service("Players"):FindFirstChild(string.sub(4)) if findplayer then findplayer.Character:BreakJoints() end end
What am I doing wrong?
I believe your error is on line 2. You had string.sub(4) which would return 'l/playername'. If you change that 4 to a 6, it'll return 'playername' instead.
Also, the layout for your string.sub was incorrect. It should be string.sub("Text",#,#) )
if string.lower(string.sub(msg, 1 , 5)) =="kill/" findplayer = game.Players:FindFirstChild(string.sub(msg, 6)) if findplayer then findplayer.Character:BreakJoints() end end
Here you go, a working and tested code:
if msg:lower():sub(1,5)=="kill/" findplayer=game:service("Players"):FindFirstChild(msg:sub(6)) -- You can't get the characters of the "string" library. It's not a text. if findplayer then findplayer.Character:BreakJoints() end end
if string.lower(string.sub(1,5),msg)=="kill/" findplayer=game.Players:FindFirstChild(string.sub(4))--no need to use getservice just use game.Players if findplayer then findplayer.Character:BreakJoints() end end