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

im so confused on this? ive been doing it for an hour and a half and it wont work

Asked by 2 years ago

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

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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 Script

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

Server Script

local replicated = game:GetService("ReplicatedStorage") 
local kickplayer = replicated:WaitForChild("KickPlayer") 

kickplayer.OnServerEvent:Connect(function(player, message) 
    if player then
        player:Kick(message)
    end
end)

Documentation

StarterGui, PlayerGui, RemoteEvent

0
They are also trying to kick a player from the client Kingu_Criminal 205 — 2y
0
I know. That's why I added a comment next to the line. xInfinityBear 1777 — 2y
0
its saying that screengui isnt valid? hudstir 0 — 2y
0
It's not a valid member of PlayerGui? It means there is no child with the name "ScreenGui" in the PlayerGui. Did you rename the ScreenGui to something else? Double check it to make sure the name is the same; if it is, try using the WaitForChild method. xInfinityBear 1777 — 2y
Ad

Answer this question