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

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

Asked by 1 year ago
Edited 1 year ago

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?

0
I edited my answer Kingu_Criminal 205 — 1y
0
Can you accept my answer? Kingu_Criminal 205 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

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()
0
im not sure what you mean, im fairly new to scripting hudstir 0 — 1y
0
please help ive been working on it for an hour and a half and it still wont work hudstir 0 — 1y
Ad

Answer this question