Do what the other people said to do. Use Kick Instead because you can add a custom message to it.
#Kick
Kick disconnects the Client from the Server. You can add a custom message instead of saying, "The game shut down" or something like that. I also like Kick since Kick is usable in Local and Normal scripts.
game:GetService("Player").Player1:Kick()
game:GetService("Player").LocalPlayer:Kick()
Kick("You have been kicked")
#Final Product
These are different variations of one script.
##Kick when players Join
###Normal Script:
game:GetService("Players").PlayerAdded:connect(function(plyr)
plyr:Kick("You've been kicked")
end)
###Local Script
game:GetService("Players").LocalPlayer:Kick("You've been kicked")
##Ban script
###Normal Script:
banned = {
["Player2"] = true,
["Player3"] = true,
["NAME_OF_PLAYER"] = true
}
game:GetService("Players").PlayerAdded:connect(function(plyr)
if banned[plyr.Name] then
plyr:Kick("You are banned")
end
end)
###Local Script
banned = {
["Player2"] = true,
["Player3"] = true,
["NAME_OF_PLAYER"] = true
}
if banned[game:GetService("Players").LocalPlayer.Name] then
game:GetService("Players").LocalPlayer:Kick("You've been kicked")
end
##Kick after 30 seconds
###Normal Script:
game:GetService("Players").PlayerAdded:connect(function(plyr)
wait(30)
plyr:Kick("You've been kicked")
end)
###Local Script
wait(30)
game:GetService("Players").LocalPlayer:Kick("You've been kicked")
Hope it helps!
#Extra
In case you're wondering why this was happening, it's because of solo mode, In solo mode the client IS the server. So if you delete the client the server gets deleted too. This won't happen on the actual game though, it only shows up on solo mode.
5 comments
With LocalPlayer it is only one player. Also, what do you mean by Delete?
http://gyazo.com/1b6a0b4112f75e0b6832a9d63ced58ef
secretboy6 You do know he means as a Lua script, not by roblox studio. No body except roblox admins has access to the studio ingame on a roblox server.
@Nickoplier Ik that. I was showing him what I'd want the player to be like in the game, Immovable and Invisible....
But this way, it's practically kicking the player, the player can't talk and you cannot bring back the player. If you do this the server ends, you might as well disconnect them.