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

im trying to make it so when you click on all items it kicks you out. it wont work how do i do it?

so i made this game where you have to get everything on a shopping list, then you completed the game, but when you collect all the items, im not sure how to kick the player out, i used the gui as the thing that kicks you out, heres the script: "

local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait() local objective1 = script.Parent.Objective1 local objective2 = script.Parent.Objective2 local objective3 = script.Parent.Objective3 local objective4 = script.Parent.Objective4

if objective1.Text == "------" and objective2.Text == "------" and objective3.Text == "------" and objective4.Text == "------"then

player:Kick("congrats, you got all the items on your shopping list!")

end

" it wont work. help?

2 comments

0

I edited my answer

0

Can you accept my answer?

1 answer

You have to fire a serverscript to kick the player, you cannot kick the player from a localscript

Basically, you can create a RemoteEvent by clicking on whatever you want to be the parent and clicking the plus and inserting one, or just add this script into ServerScriptService

local event = Instance.new("RemoteEvent")
event.Name = "KickEvent"
event.Parent = game.ReplicatedStorage

local kickmessage = "congrats, you got all the items on your shopping list!"

local function kick(plr)
	print("The function has been called on " ..plr.Name.. ". Kicking them!"
	plr:Kick(kickmessage)
	
end

event.OnServerEvent:Connect(kick)

and replace your kick within the localscript with this

local event = game.ReplicatedStorage:WaitForChild("KickEvent")
event:FireServer()

2 comments

0

im not sure what you mean, im fairly new to scripting

0

please help ive been working on it for an hour and a half and it still wont work

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