Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Admin System Can't Find The Player?

Asked by 7 years ago

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

Log in to vote
1
Answered by 7 years ago

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.

1
To be honest, this makes me wanna start working on something like this... Br4veh3art23 46 — 7y
1
Me too AdministratorReece 193 — 7y
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. animelover6446 41 — 7y
0
Ah. Makes sense. Br4veh3art23 46 — 7y
0
There's a very major problem with this code: What if the player isn't in the server? The script will error. ;c TheeDeathCaster 2368 — 7y
Ad

Answer this question