local TweenService = game:GetService("TweenService")
script.Parent.Close_Button.MouseButton1Click:Connect(function()
script.Parent:Destroy()
end)
local CountdownTime = script:WaitForChild("Value")
TweenService:Create(script.Parent, TweenInfo.new(0.4), {
Size = UDim2.new(1, 0, 0.15, 0)
}):Play()
coroutine.wrap(function()
while true do
CountdownTime.Value = CountdownTime.Value - 1
script.Parent.Timer_Label.Text = tostring(CountdownTime.Value) .. " seconds"
task.wait(1)
if CountdownTime.Value == 0 then
break
end
end
script.Parent:Destroy()
end)()
I completed the ClientSide of my countdown command gui, but I can’t figure how I can create the serverside which clones the countdown template and puts it in startergui, with the title being “Username’s Countdown”.
1 Like
you can just use a remote event that when it is called will give everyone the countdown
example:
local gui = script.gui
local remote = game:GetService("ReplicatedStorage").RemoteEvent
remote.OnServerEvent:Connect(function(plr, countdown)
for _,plr in pairs(game:GetService("Players"):GetPlayers()) do
local clone = gui:Clone()
clone.Parent = plr.PlayerGui
for i = 1,countdown do
clone.countdown.Text = plr.Name.."'s countdown: "..countdown - i
wait(1)
end
clone:Destroy()
end
end)
messy code but you get the idea
How would I detect who sent it?
game.Players.LocalPlayer.Chatted:Connect(function(msg)
local sm = msg:split(" ")
local countdown = sm[2]
game.ReplicatedStorage.Countdown:FireServer(plrig, countdown)
end)
local script
if it is local then it would just be game.Players.LocalPlayer.Name
1 Like
No, I meant when firing the server.
if it is from the remote then the first argument is the player so the first argument.Name
This is my firing server code.
game.Players.LocalPlayer.Chatted:Connect(function(msg)
local sm = msg:split(" ")
local plr = game.Players.LocalPlayer
local countdown = sm[2]
game.ReplicatedStorage.Countdown:FireServer(plr, countdown)
end)
It doesn’t show the correct countdown times. I set it to 200.
local gui = script.Template
game:GetService("ReplicatedStorage").Countdown.OnServerEvent:Connect(function(plr, countdown)
for _,plr in pairs(game:GetService("Players"):GetPlayers()) do
local clone = gui:Clone()
clone.Parent = plr.PlayerGui.GameplayGui.CountdownGui
clone.Top_Bar.TextLabel = plr.Name.."'s countdown: "
clone.CountdownHandler.Value = countdown
wait(1)
clone:Destroy()
end
end)
Replace clone.CountdownHandler.Value = countdown
with
for i = 1,countdown+1 do
clone.CountdownHandler.Value = countdown-i+1
wait(1)
end
Attempt to perform arethmatic on instance and number??
show me the script so I can see what instance it is trying to add, I tested it and it worked on my studio
local gui = script.Template
game:GetService("ReplicatedStorage").Countdown.OnServerEvent:Connect(function(plr, countdown)
for _,plr in pairs(game:GetService("Players"):GetPlayers()) do
local clone = gui:Clone()
clone.Parent = plr.PlayerGui.GameplayGui.CountdownGui
clone.Top_Bar.TextLabel.Text = plr.Name.."'s countdown: "
for i = 1,countdown+1 do
clone.CountdownHandler.Value = countdown-i+1
wait(1)
end
clone.CountdownHandler.Enabled = true
end
end)
It isnt the actual script itself but the arguments being passed into the remote that is causing this. Try replacing countdown with tonumber(countdown) to see if that does anything (by this I mean the 2 last countdowns)
local gui = script.Template
game:GetService("ReplicatedStorage").Countdown.OnServerEvent:Connect(function(plr, countdown)
for _,plr in pairs(game:GetService("Players"):GetPlayers()) do
local clone = gui:Clone()
clone.Parent = plr.PlayerGui.GameplayGui.CountdownGui
clone.Top_Bar.TextLabel.Text = plr.Name.."'s countdown: "
for i = 1, tonumber(countdown)+1 do
clone.CountdownHandler.Value = tonumber(countdown)-i+1
end
clone.CountdownHandler.Enabled = true
end
end)
oh, all else I can think of is making sure CountdownHandler is an intvalue
No, it’s the client side script that handles countdown label, destroying ita fter the countdown is over, etc.
Under that, “Countdown” is a value.
Note: I fixed the script to fix the values, but it still displays the same error.
Additionally, it’s a numbervalue.
Is the client side script replicated for all clients? if not then that may be your problem, If it is on 1 client it means the server cant access it