Need help with time tracking system

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I am attempting to make a time tracking system to track a players time in game and use each second in game as a sort of point, and you can check these points via a proxmity prompt that pulls up a basic GUI.

  2. What is the issue? The code that actually manages the GUI doesnt work, and its not very much code so im not sure why. There are no errors that I can find, even when testing in an empty baseplate. The main issue I think is with the .Changed event, as it doesnt seem to be firing.

  3. What solutions have you tried so far? Using developer hub, youtube, and the api documenation.

I can confirm that the TimeValue object referenced is there when the script attempts to reference it, and that there are no issues that stem from the script not finding the TimeValue object.

script.Parent.ProximityPrompt.Triggered:Connect(function(playerWhoTriggered)
	local newClone = script.ExperienceView:Clone()
	local givenValue 
	--(correctedStartValue * 1) / range 

	playerWhoTriggered.TimeValue.Changed:Connect(function(e) -- Time value is the value that tracks seconds in game, this is where I think it is failing.
		print("aypo")
		givenValue = e
		local newValue = (givenValue * 1) / 900 -- Calculate percentage for udim2
		print(newValue)
		newClone.ProgressBar.ProgressionBar.Size = UDim2.new(newValue, 0, 1, 0) -- sets size

		local remaining = 900 - newValue -- how much time needed for next rank
		newClone.Remaining.Text = tostring(remaining) -- converts said time into string form



	end)

	newClone.Parent = playerWhoTriggered.PlayerGui -- sets gui parent to player

end)

Whats the point of multiplying givenValue with 1?

1 Like

You need to use TimeValue.Value As TimeValue is just the object.

1 Like

I wasn’t even thinking when I wrote that. Ignore that part.

you can’t use TimeValue.Changed and expect “e” to be the value, “e” would be the name of the property that changed (in this case it would be “Value”). So, if you want to fire the event whenever the Value changes, use

TimeValue:GetPropertyChangedSignal("Value"):Connect(function()

and then set givenValue to TimeValue.Value

givenValue = TimeValue.Value

You are also doing

local remaining = 900 - newValue

but it should be this, (because newValue is the percentage)

local remaining = 900 - givenValue

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.