Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to remove a player (script) on studio?

How I remove a player permenantly on studio? (A script) I tried many methods.

4 comments

0

can you post some of them, please?

1

Excuse me but I am wondering why would you want to delete the player in the first place?

0

@ UserOnly16Characters , for a ban script maybe?

0

Um, if you're trying to test without a player, do Run (green arrow for the ribbon studio)

2 answers

You just need to get the player somehow. or you can use the method getplayerfromcharacter and then kick the player.

Pretty simple actually.

local player = game.Players.LocalPlayer

player:Kick()

3 comments

0

This script would be in a localscript

0

con, can you tell me, how does he localize the player he wants to delete?

0

He could just rejoin the game couldn't he?!

I will not make the script, you must do it yourself. Now I will give you hints on how to make one.


Hints

  1. PlayerAdded
  2. Kick()
  3. DataStores/DataPersistance


PlayerAdded

The event is a member of the Players service. It fires once a person joins the game.

game:GetService("Players").PlayerAdded:connect(function(player)
	print(player.Name.." has joined the game!")
end)

Fun Facts about PlayerAdded

  1. It's has a counterpart, PlayerRemoving. It's not PlayerLeaving!
  2. PlayerAdded cannot be fired in a local script!


Kick

The kick functions kicks the player. It has a secret parameter where you can add text. The text shows up when the player gets kicked.

game:GetService("Players").Player1:Kick("You have been kicked from my game!")

Fun Fact about Kick

  1. People used to do :Destroy() instead of Kick!


Data

DataStores is a way to save data. Same with DataPersistence. DataStores works within a game's universe. DataPersistence only saves within a place.

--DataStores
local name = "Test"
local datastore = game:GetService("DataStoreService"):GetDataStore(name)

or

game:GetService("Players").Player:SaveBool(true, "Test")

Fun fact about Data

  1. DataStores saves within universes or Games and DataPersistence only saves withing PLACES.



Final Product

local ban = game:GetService("DataStoreService"):GetDataStore("Ban")
local text = "You are banned."
bannedlist = {"Player1"}

game:GetService("Players").PlayerAdded:connect(function(plyr)
	if ban:GetAsync("user_"..plyr.userId) ~= nil then
		if ban:GetAsync("user_"..plyr.userId) == true then
			plyr:Kick(text)
		end
	else
		for _,n in pairs(bannedlist) do
			if n == plyr.Name then
				ban:SetAsync("user_"..plyr.userId, true)
				plyr:Kick(text)
			end
		end
	end
end)

Watch out! This

This discussion is preserved as it was. New answers, comments, and votes are closed.