You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I am trying to make a player based timer (different for each player). -
What is the issue? Include screenshots / videos if possible!
The timer replicates across all clients in the game. (This ruins other peoples times mid run.) -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve searched around and have found nothing that could help and all solutions I’ve thought of don’t seem to work as far as I have tested.
local function Init(Payer)
local self = Timers[Player] or {}
self.Red = Color3.fromRGB(255, 75, 75)
self.Green = Color3.fromRGB(75, 255, 75)
self.Tick = 0
self.Time = 0
self.Snap = 0
self.Active = false
self.Record = nil
self.Runtime = RenderStepped:Connect(function() end)
self.Runtime:Disconnect()
self.Update = function()
self.Time = (time() - self.Tick)
self.Snap = (self.Record and math.clamp((self.Time / self.Record), 0, 1) or 1)
TimeLabel0.Text = TimerClass.GetRealTime(self:RawTime())
TimeLabel1.Text = (self.Record and TimerClass.GetRealTime(self.Record) or TimerClass.GetRealTime(self:RawTime()))
BarFrame0.Size = UDim2.new(self.Snap, 0, 1, 0)
BarFrame1.Size = UDim2.new((1 / self.Snap), 0, 1, 0)
BarFrame1.BackgroundColor3 = (self.Record and (self.Green:Lerp(self.Red, self.Snap)) or self.Green)
end
self.Play = function()
self.Tick = time()
self.Active = true
self.Runtime = RenderStepped:Connect(self.Update)
end
self.Pause = function()
if not self.Active then return end
if not self.Runtime then return end
self.Runtime:Disconnect()
end
self.Reset = function()
if not self.Active then return end
if not self.Runtime then return end
self.Tick = 0
self.Active = false
self.Runtime:Disconnect()
if self.Record then
if self.Time < self.Record then
self.Record = self.Time
end
else
self.Record = self.Time
end
TimeLabel0.Text = TimerClass.GetRealTime(self:RawTime())
end
function self:RawTime()
return self.Time
end
return self
end