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

Confused on how to do a /kick chatted event?

Asked by 5 years ago

So Im trying to make a command where if a developer chats "/kick (players name)" it kicks them, but i'm super confused on how to reference the player. Any help?

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        if msg == "/kick"..game.Players:GetPlayers().Name then
            game.Players:GetPlayers().Name:Kick()
        end
    end)
end)
0
How about a while true do loop and for loop that consistently checks if there is a player in the game who is a developer? If they are then you can execute the code however you want. Pojoto 329 — 5y
0
That's not the problem, the problem is I can't reference the player from a message. SBlankthorn 329 — 5y
0
Oooh. Pojoto 329 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I figured it out lol.

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        if string.sub(msg,1,5) == "/kick" and plr:FindFirstChild("DEVELOPER") ~= nil then
            local player = game.Players:FindFirstChild(string.sub(msg,7))
             if player then
                player:Kick()
            end
        end
    end)
end)
0
there's like only 2 differences from pawels answer... Vulkarin 581 — 5y
0
Not only that, but you also didn't mention that for this to work there would have to be a tag called "DEVELOPER" in the player. MythicalShade 420 — 5y
0
@MythicalShade Ik, because that was uneeded at the time. You did exactly want I wanted. SBlankthorn 329 — 5y
0
Why was this downvoted? User#19524 175 — 5y
0
Oh my bad SBlankthorn I didn't realize you were the person asking the question so I thought that the person asking the question wouldn't understand the "Developer" part lmao my bad. MythicalShade 420 — 5y
Ad

Answer this question