Hi im back again this is my second post my first post got flagged for some reason anyways i can’t make a round system i tried so many times i tried a new script this one didn’t work too its a server script in server script service
here is my code
local players = game.Players:GetPlayerFromCharacter().Character
local countDown = game.ReplicatedStorage.Time
while true do
wait(1)
countDown.Value = countDown.Value -1
game.StarterGui.ScreenGui.TextLabel.Text = countDown.Value
if countDown.Value == 0 then
game.StarterGui.ScreenGui.TextLabel.Visible = false
players.PrimaryPart.Position = game.Workspace.Part.Position
break
end
end
it shows an error in the output but i don’t understand it so please help
1 Like
Hi. imma be back in 30 minutes!!
@LordBoboux edited
you’re having several errors in your script
you’re getting nothing in getplayerfromcharacter, did you mean game:GetService("Players"):GetChildren()?
second, you’re getting from StarterGui
add a remote event in Replicated storage, name it whatever you want,
--existing serverscript
--local players = game.Players:GetChildren() --unessecary rn
local countDown = game:GetService("ReplicatedStorage"):WaitForChild("Time") --yield script until these are found
local event = game:GetService("ReplicatedStorage"):WaitForChild("whateverremoteeventname") --replace with remote event's name
while true do
wait(1)
countDown.Value = countDown.Value - 1
if countDown.Value == 0 then
event:FireAllClients() --fire to all clients in server
break
end
end
add a local script to StarterPlayer → StarterPlayerScripts
copypaste this
local event = game:GetService("ReplicatedStorage"):WaitForChild("whateverremoteeventname") --replace with remote event's name
local playergui = script.Parent.Parent:WaitForChild("PlayerGui") --get client player gui
local textlabel = playergui:WaitForChild("ScreenGui").TextLabel
while wait() do
textlabel.Text = game:GetService("ReplicatedStorage").countDown.Value
end
event.OnClientEvent:Connect(function() --if fired to all clients
textlabel.Visible = false
game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.CFrame = workspace.Part.CFrame -- cframe is better and LocalPlayer is the player of what the localscript is controlling, it is highly recommended to change the name of your part, since there are various other parts with the same name.
end)
I’m guessing you’re trying to move all players. This should do the trick:
local players = game.Players
local countDown = game.ReplicatedStorage.Time
while true do
wait(1)
countDown.Value = countDown.Value -1
for _,Player in next, players:GetPlayers() do
Player.PlayerGui.ScreenGui.TextLabel.Text = countDown.Value
end
if countDown.Value == 0 then
game.StarterGui.ScreenGui.TextLabel.Visible = false
for _,Player in next, players:GetPlayers() do
Player.Character.PrimaryPart.Position = game.Workspace.Part.Position
end
end
end
Hi. yes I will try that too xD.
1 Like
Hi again. yes that did teleport players but the gui only works when the game isn’t loaded once the game is loaded the gui text freezes and i also checked the time value in replicatedstorage and the value went below -1
Alright, I added a break block so the loop stops at 0.
Also, ScreenGui have a property that might be causing the freeze issue. Select the gui in the explorer and set “ResetOnSpawn” to false.
local players = game.Players
local countDown = game.ReplicatedStorage.Time
while true do
wait(1)
countDown.Value = countDown.Value -1
for _,Player in next, players:GetPlayers() do
Player.PlayerGui.ScreenGui.TextLabel.Text = countDown.Value
end
if countDown.Value == 0 then
game.StarterGui.ScreenGui.TextLabel.Visible = false
for _,Player in next, players:GetPlayers() do
Player.Character.PrimaryPart.Position = game.Workspace.Part.Position
end
break
end
end
1 Like
Hi. again. yes that worked like a charm
But it didn’t hide the gui when text was 0 but i guess thats an issue i can fix myself
1 Like