This is the localscript. I want to be a server script so that the time replicates across other clients.
local parent = script.Parent
local player = game.Players.LocalPlayer
local leaderstats = player.leaderstats
local TimeStat = leaderstats and leaderstats:FindFirstChild("Time")
local Highscore = leaderstats and leaderstats:FindFirstChild("TopTime")
parent.Parent = script.Parent.Parent.Head
wait(1)
while wait(0) do
if player.Character:FindFirstChild("ForceField") then
parent.TimeLabel.IsInSpawn.Value = true
else
parent.TimeLabel.IsInSpawn.Value = false
end
if parent.TimeLabel.IsInSpawn.Value == false and player.Character.Humanoid.Health ~= 0 then
parent.TimeLabel.Time.Value = parent.TimeLabel.Time.Value + 1
parent.TimeLabel.Text = parent.TimeLabel.Time.Value
TimeStat.Value = parent.TimeLabel.Time.Value
if TimeStat.Value > Highscore.Value then
Highscore.Value = TimeStat.Value
end
wait(1)
end
end
player.Character:WaitForChild("Humanoid").Died:Connect(function()
parent.TimeLabel.Time.Value = 0
end)
First, you need to create a RemoteEvent in ReplicatedStorage called “Time”. Then, whenever you change the time value, fire the remote event to the server and you can then use that data to replicate it to all clients.
Well imagine if an exploiter can change any value sent to the server. If it’s game breaking or very important, then do the time checking for all players on the server instead of the client. If it won’t bother you if a value is changed, then don’t worry about it.