local replicated = game:GetService("ReplicatedStorage") local kickplayer = replicated:WaitForChild("KickPlayer") local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait() local objective1 = game.StarterGui.ScreenGui.Frame.Objective1 local objective2 = game.StarterGui.ScreenGui.Frame.Objective2 local objective3 = game.StarterGui.ScreenGui.Frame.Objective3 local objective4 = game.StarterGui.ScreenGui.Frame.Objective4
if objective1.Text == "------" and objective2.Text == "------" and objective3.Text == "------" and objective4.Text == "------"then function kickplayerfromgame() player:Kick("congrats") end
kickplayer.OnClientEvent:Connect(kickplayerfromgame)
end
im trying tomake it so when you click on multiple items itll kick you out of the game but i dont understand at all i really need help
As the StarterGui service is only a container object that holds the GUI objects, you can not manipulate the GUI objects that reside inside the StarterGui. When a player joins the game, all the GUI objects will be cloned into the player's PlayerGui.
The Kick
method only works on the server so you will need to use a Remote Event. Remote Events allow communication between the server and client. You will need to use the FireServer
method which will fire the OnServerEvent event on the server; you can then pass the parameters you want.
local replicated = game:GetService("ReplicatedStorage") local kickplayer = replicated:WaitForChild("KickPlayer") local player = game.Players.LocalPlayer local playerGui = player.PlayerGui local objective1 = playerGui.ScreenGui.Frame.Objective1 local objective2 = playerGui.ScreenGui.Frame.Objective2 local objective3 = playerGui.ScreenGui.Frame.Objective3 local objective4 = playerGui.ScreenGui.Frame.Objective4 if objective1.Text == "------" and objective2.Text == "------" and objective3.Text == "------" and objective4.Text == "------"then kickplayer:FireServer("congrats") end
local replicated = game:GetService("ReplicatedStorage") local kickplayer = replicated:WaitForChild("KickPlayer") kickplayer.OnServerEvent:Connect(function(player, message) if player then player:Kick(message) end end)