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

How do I make this kill cmd script only for one player?

Asked by
iHavoc101 127
5 years ago

I want to make it so only a specific player can do this:

function chat(msg, sender)

    local delimiter_point=msg:find("/", 1, true) --Find the delimiter in the string

    if delimiter_point then --Make sure it's actually there

        local command = msg:sub(1, delimiter_point-1)

        local arg = msg:sub(delimiter_point+1)

        --We have the command and argument. It's now time to start with the commands :D



        if command == "message" then

            local x = Instance.new("Message", Workspace) --Create a message

            x.Text = arg --Set its text to the text after the delimiter

            game.Debris:AddItem(x, 5) --Remove the message after five seconds.

        elseif command == "kill" then

            if game.Players:findFirstChild(arg) then --See if player is in game

                local x = game.Players:findFirstChild(arg) -- Set a variable for the player found

                if x.Character then --Make sure the player has a character so we can kill it

                    x.Character:BreakJoints() --If character found, then kill character.

                end

            end

        end

    end

end



game.Players.PlayerAdded:connect(function(plr)

    repeat wait() until plr.Character

    plr.Chatted:connect(function(msg)

        chat(msg, plr)

    end)

end)
0
if sender ~= 'username' then return end BuDeep 214 — 5y
0
Try if plr.UserId == "Your UserId" then chat(msg, plr) end Yuuwa0519 197 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
game.Players.PlayerAdded:Connect(function(plr) -- THIS EVENT RUNS WHEN A PLAYER IS ADDED TO THE GAME
    if plr.UserId == 000000000 then --CHECKS THE USER ID OF THE PLAYER [REPLACE 000000000 WITH THE USER'S ID]
    --THE SCRIPT YOU PUT HERE WILL RUN ONLY IF THE PLAYER'S USER ID IS THE SET USER ID
    end
end)
Ad

Answer this question