Value stacking with a timer

Basically, I’m trying to make it so when a property of an object doesnt change in a given amount of time, it will reset. When the player’s cash changes, a text shows up on their screen telling them the difference between the money they had before the cash changed. Like, ‘You made 25 dollars’. This text would update everytime the coins change again, ‘You made (50/75/100, etc) dollars.’ But if it doesnt update in
3 seconds, the text will fade.

Oversimplified, how do you make a time reset if a intvalue’s number changes.

How would I go around this?

So you wanna have a script that continuously checks a property to see if it has changed, & if it hasn’t changed after that time to reset, and if it has to do something else?

There’s nothing updating the timer, so that won’t work. Thanks tho

I’m just struggling to follow what you’re trying to do

I’m trying to make it so when someones cash changes, a text pops up, telling them how much cash they lost/made. After a certain amount of time the text will fade. But if the value changes once again it will delay the fade time.

It’s very difficult to explain.

I’m not sure how you expect us to be able to further support you.

Can the reset begin if the fade has already started, or only before the fading has begun? And if the reset can occur mid-fade, how are you currently implementing the gradual fading effect?

This is my code, maybe it will help you understand this.

local coinstatuss = game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Coins")

local waiting = 2

local vv = false

coinstatuss.Changed:Connect(function(nsg)
	
	waiting = 2
	
	local dif = nsg - coinstatus
	local ts = game:GetService("TweenService")
	
	local goals = {Value = coinstatus + dif}
	
	local ti = TweenInfo.new(
		3,
		Enum.EasingStyle.Quart,
		Enum.EasingDirection.InOut,
		0,
		false,
		0
	)
	
	ts:Create(script.Parent.V, ti, goals):Play()
	
	local g2 = {TextSize = 30, TextTransparency = 0}
	local g3 = {TextSize = 14, TextTransparency = 1}
	
	local ti2 = TweenInfo.new(
		.5,
		Enum.EasingStyle.Bounce,
		Enum.EasingDirection.InOut,
		0,
		false,
		0
	)
	
	
	local s
	
	if nsg < coinstatus then
		s = ""
	else
		s = "+"
	end
	
	script.Parent.CoinCollectin.Text = s..dif.."$"
	
	local gg2 = ts:Create(script.Parent.CoinCollectin, ti2, g2)
	local gg3 = ts:Create(script.Parent.CoinCollectin, ti2, g3)
	
	gg2:Play()
	gg3:Pause()
	
	--[[script.Parent.CoinCollectin.Changed:Connect(function(val)
		gg2:Play()
		gg3:Pause()
		waiting = 2
	end)]]

	task.wait(waiting)
	
	gg3:Play()
end)

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