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

I made a simple kick script and it doesn't work any ideas?

Asked by 5 years ago
Edited 5 years ago
local players = game:GetService("Players")

players.PlayerAdded:connect(function(player)
local banned = player.name == "playername"
banned:kick("You are banned!")


end)
0
this script was wild from start to finish. DinozCreates 1070 — 5y
0
Which parts do I need to fix I don't really understand kick scripts very much voidofdeathfire 148 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago

banned is assigned as a boolean resulting from: player.name == "playername". First off, player.name has to be player.Name, Kick too.

What you probably want to use is an if statement, here's the syntax:

if (condition) then
    -- do stuff
end

^do stuff only runs when the condition is true

We can use this to kick the player only when their player name player.Name is equal == to whatever name you want "playername":

game:GetService("Players").PlayerAdded:Connect(function(player) -- note that I made "connect" into "Connect" because "connect" is deprecated and may be removed in the future
    if player.Name == "playername" then -- can omit brackets ()
        player:Kick("You are banned!") -- kicks player with warning
    end
end)

If we were to "translate" line 2-4 to English we would say:

if the player's name is "playername" then kick the player with the warning "You are banned!"

yeah not much difference ik lol

Ad

Answer this question