Issue with my stopwatch

What I am trying to achieve is to have a timer displayed on top of your head.

I tried making the script only client-sided and it worked perfectly yet I as soon as I attempted to make it server sided it jsut didn’t work. (please be patient with me as I am still learning)

Main local script

image

local Timer = script.Parent

local Player = game:GetService("Players").LocalPlayer
local PlayerVals = Player:WaitForChild("PlayerVals")

local Updater = game:GetService("ReplicatedStorage"):FindFirstChild("Timer")

local Timer = script.Parent

local RunService = game:GetService("RunService")
local Seconds = PlayerVals:WaitForChild("Seconds")

local Stop_Watch_Text = script.Parent.TextLabel


Updater.OnClientEvent:Connect(function(timer)

game.Players.PlayerAdded:Connect(function(plr)

	local TimeFolder = Instance.new("Folder")
	TimeFolder.Name = "PlayerVals"
	TimeFolder.Parent = plr

	local Seconds = Instance.new("IntValue")
	Seconds.Name = "Seconds"
	Seconds.Parent = TimeFolder

	while wait(1) do
		Seconds.Value += 1
	end
end)
	RunService.RenderStepped:Connect(function()
		Stop_Watch_Text.Text = Seconds.Value
	end)
end)

Here is the script which i believe is meant to receive the event

image

local Remote = game:GetService("ReplicatedStorage"):FindFirstChild("Timer")

Remote:FireAllClients()

I understand my scripts may seem really dumb, but I would truly appreciate any sort of help, thanks!

No need of the while loop:

local count = 0
local interval = 1 --number of secs after which the event will fire.

RunService.RenderStepped:Connect(function(dt)
	counter += dt
    if counter >= interval then
         counter -= interval
         -- fire ur event/set seconds.Value.
    end
end)

And u shud be doing it vice-versa, that is setting the timer on the server and firing an event to the client.

Sorry but I don’t really understand what you mean

Same question, what do u want to happen? Cuz rn ur just firing the remote pointlessly.

Basically just need this billboardGUI to change its value +1 every second

image

Only a localscript is needed (depending on whether u want it to be exploitable or not):

local Timer = script.Parent

local Player = game:GetService("Players").LocalPlayer
local PlayerVals = Player:WaitForChild("PlayerVals")

local Timer = script.Parent

local RunService = game:GetService("RunService")

local Stop_Watch_Text = Timer.TextLabel

local count = 0
local interval = 1 --number of secs after which the event will fire.

RunService.RenderStepped:Connect(function(dt)
	counter += dt
    if counter >= interval then
         counter -= interval
         Stop_Watch_Text.Text = tostring(tonumber(Stop_Watch_Text.Text) + 1) 
    end
end)

Make sure the original text is set to “0” for this script to work.

Alright thanks, the script did work, however it is not fully server sided


So rather than using a surgace gui, use a billboard gui, which can be parented to a players head server sided and can contain a textlabel, which can be updated from the server.

It doesn’t matter which is used, both a SurfaceGui and BIllboardGui could work.