Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Admin System Can't Find The Player?

Alright, so the other day I thought it would be fun to make my own personal admin system. For no one else's use except mine. So, I made the first basic command and I'm already hitting a blockade. For some reason, this isn't working and I'm not quite sure why. Here's my script:

repeat wait() until game.Players.LocalPlayer.Character

Player = game.Players.LocalPlayer
Char = Player.Character

Player.Chatted:connect(function(Message)
	local Length = string.len(Message)
	print(Length)
	if Message:sub(1, 15) == "System Command:" then
		print("First Step")
		if Message:sub(17, 20) == "Kill" then
			print("Second Step")
			local Target = Message:sub(21)
			game.Workspace:FindFirstChild(Target).Torso:Remove()
		end
	end
end)

So this SAO-esque script is actually a LocalScript in StarterPack This is the error I'm getting: https://gyazo.com/65e08ad8cf12b208820d0ba09765b857 (The link function wouldn't work/is broken)

Thanks in advance

1 answer

✓ Accepted answer

Well, unless you want the command to be "System Command: KillSnaz_X", you're gonna need to change Target to "Message:sub(22)". Also, it'll look better if you just take all the health from the humanoid:

repeat wait() until game.Players.LocalPlayer.Character 
Player = game.Players.LocalPlayer 
Char = Player.Character 
Player.Chatted:connect(function(Message) 
	local Length = string.len(Message) 
	print(Length) 
	if Message:sub(1, 15) == "System Command:" then 
		print("First Step") 
		if Message:sub(17, 20) == "Kill" then 
			print("Second Step") 
			local Target = Message:sub(22) 
			game.Workspace:FindFirstChild(Target)["Humanoid"].Health = 0 
		end 
	end 
end)

Now, Just say "System Command: Kill Snaz_X" and your character will die.

5 comments

1

To be honest, this makes me wanna start working on something like this...

1

Me too

0

Ah, thank you. Such a simple mistake. Also, the reason I was removing the torso was just in case someone was to exploit their health.

0

Ah. Makes sense.

0

There's a very major problem with this code: What if the player isn't in the server? The script will error. ;c

This discussion is preserved as it was. New answers, comments, and votes are closed.