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

How to remove a player (script) on studio?

Asked by 9 years ago

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

0
can you post some of them, please? davness 376 — 9y
1
Excuse me but I am wondering why would you want to delete the player in the first place? UserOnly20Characters 890 — 9y
0
@ UserOnly16Characters , for a ban script maybe? EzraNehemiah_TF2 3552 — 9y
0
Um, if you're trying to test without a player, do Run (green arrow for the ribbon studio) alphawolvess 1784 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

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()

0
This script would be in a localscript ScriptingCon 52 — 9y
0
con, can you tell me, how does he localize the player he wants to delete? davness 376 — 9y
0
He could just rejoin the game couldn't he?! EzraNehemiah_TF2 3552 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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

Answer this question