So basically I have this game where you go around collecting stuff. I don't have an idea on what I do for when everyone finds the objects, so I'm just trying to make the game kick everyone when all the objects have been found.
Here is my script
local player = game:GetService("Players") local RS = game.ReplicatedStorage local PN = RS.PlayerName if PN.Value == "Restarting..." then wait(10) for i, player in pairs(player:GetPlayers()) do player:Kick("Game has ended!") end end
BTW the PN part isnt only for playerName, its a StringValue that changes the text of a label I have in StarterGUI, so i'm basically trying to make it so when the text is saying "Restarting..." wait 10 seconds then kick everyone but when i'm testing the game it doesn't kick. I'm not to familiar with using :Kick so I could just be doing something wrong.
So basically I was just being an idiot. I thought I had to make a whole new script so it could kick someone when the test said "Restarting" but all I had to do was go into my local script for the textLabel and basically say this
if BC.Value == 6 then script.Parent.Text = ReplicatedStorage.Restart.Value wait(3) local player = game:GetService("Players") for i, player in pairs(player:GetPlayers()) do player:Kick("Game is Over") end end
I thought you could only use
local player = game:GetService("Players")
In a normal script and
local player = game.Player.LocalPlayer
For a local script.
Well this whole thing was just me being dumb lol.
Well you can listen to the StringValue .Changed event to detect if the StringValue has changed and then proceed accordingly.
StringValue.Changed:Connect(function() --Do stuff end)
I'd recommend doing it this way though.
StringValue:GetPropertyChangedSIgnal("Value"):Connect(function() --Do stuff end)