Hello!
Ok so, I am trying to make a timer system for a daylight cycle in my simulator game. The way it works it that there will be a max time, in this case 15 minutes, and when the timer ends, it will become night/day. Continuing, I want the player to be able to cancel it if they’re in a private server (they will have a button that will cancel the timer).
I’ve made the TimerScript which runs off the DayTimeEvent.
DayTimeEventScript- In StarterCharacterScripts and it’s a LocalScript
TimerCancelScript - In StarterCharacterScripts and it’s a LocalScript
Here’s the DayTimeEventScript:
local ReplicatedStorage = game.ReplicatedStorage
local RemoteEvents = ReplicatedStorage.RemoteEvents
local CycleDayEvent = RemoteEvents.CycleDayEvent
local UI = game.Players.LocalPlayer.PlayerGui.Main
local TextLabel = UI.TextLabel
local Text = TextLabel.Text
local function CycleTimer()
TextLabel.Visible = true
Text = "15 Minutes"
wait(60)
Text = "14 Minutes"
wait(60)
Text = "13 Minutes"
wait(60)
Text = "12 Minutes"
wait(60)
Text = "11 Minutes"
wait(60)
Text = "10 Minutes"
wait(60)
Text = "9 Minutes"
wait(60)
Text = "8 Minutes"
wait(60)
Text = "7 Minutes"
wait(60)
Text = "6 Minutes"
wait(60)
Text = "5 Minutes"
wait(60)
Text = "4 Minutes"
wait(60)
Text = "3 Minutes"
wait(60)
Text = "2 Minutes"
wait(60)
Text = "1:00"
wait(1)
Text = "00:59"
wait(1)
Text = "00:58"
wait(1)
Text = "00:57"
wait(1)
Text = "00:56"
wait(1)
Text = "00:55"
wait(1)
Text = "00:54"
wait(1)
Text = "00:53"
wait(1)
Text = "00:52"
wait(1)
Text = "00:51"
wait(1)
Text = "00:50"
wait(1)
Text = "00:49"
wait(1)
Text = "00:48"
wait(1)
Text = "00:47"
wait(1)
Text = "00:46"
wait(1)
Text = "00:45"
wait(1)
Text = "00:44"
wait(1)
Text = "00:43"
wait(1)
Text = "00:42"
wait(1)
Text = "00:41"
wait(1)
Text = "00:40"
wait(1)
Text = "00:39"
wait(1)
Text = "00:38"
wait(1)
Text = "00:37"
wait(1)
Text = "00:36"
wait(1)
Text = "00:35"
wait(1)
Text = "00:34"
wait(1)
Text = "00:33"
wait(1)
Text = "00:32"
wait(1)
Text = "00:31"
wait(1)
Text = "00:30"
wait(1)
Text = "00:29"
wait(1)
Text = "00:28"
wait(1)
Text = "00:27"
wait(1)
Text = "00:26"
wait(1)
Text = "00:25"
wait(1)
Text = "00:24"
wait(1)
Text = "00:23"
wait(1)
Text = "00:22"
wait(1)
Text = "00:21"
wait(1)
Text = "00:20"
wait(1)
Text = "00:19"
wait(1)
Text = "00:18"
wait(1)
Text = "00:17"
wait(1)
Text = "00:16"
wait(1)
Text = "00:15"
wait(1)
Text = "00:14"
wait(1)
Text = "00:13"
wait(1)
Text = "00:12"
wait(1)
Text = "00:11"
wait(1)
Text = "00:10"
wait(1)
Text = "00:09"
wait(1)
Text = "00:08"
wait(1)
Text = "00:07"
wait(1)
Text = "00:06"
wait(1)
Text = "00:05"
wait(1)
Text = "00:04"
wait(1)
Text = "00:03"
wait(1)
Text = "00:02"
wait(1)
Text = "00:01"
wait(1)
Text = "00:00"
end
CycleDayEvent.OnClientEvent:Connect(function()
Timer()
end)
So far, I’ve tried making a script to cancel it which is as follows:
local ReplicatedStorage = game.ReplicatedStorage
local RemoteEvents = ReplicatedStorage.RemoteEvents
local CancelCycleTimerEvent = RemoteEvents.CancelCycleTimerEvent
local function CancelTimer()
local PlayerGui = game.Players.LocalPlayer.PlayerGui
local TextLabel = PlayerGui.Main.TextLabel
local TextLabelClone = ReplicatedStorage.Extras.TextLabel:Clone()
TextLabel:Destroy()
TextLabelClone.Parent = PlayerGui.Main
TextLabelClone.Name = "TextLabel"
end
I feel like what I’ve scripted is wrong and I don’t know what about the script could be wrong. If anyone could look over the scripts and see how I can change the CancelEvent script much would be appreciated. Ask questions if needed.
Thanks!