Hi, so long i did not ask something on this forum,
i making popup that show when value changed, but i got some issue, the trace condition, here is my script
local rootFrame = script.Parent
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local leaderstats_solved : IntValue = leaderstats:WaitForChild("Solved")
local mainText = rootFrame.show
local lastValue = 0
local replicatedStorage = game:GetService("ReplicatedStorage")
local popup_gui = replicatedStorage.assets.gui.solved
local popup_sound = replicatedStorage.assets.sound.popup
local cache = player.PlayerGui.cache
local waitTime = 1
local soundService = game:GetService("SoundService")
function setText()
end
function showPopup()
local popup = popup_gui:Clone()
popup.Position = UDim2.new(math.random(40, 70) / 100, 0, math.random(40, 70) / 100, 0)
popup.Parent = cache
soundService:PlayLocalSound(popup_sound)
task.wait(1)
popup:TweenPosition(rootFrame.Position, Enum.EasingDirection.In, Enum.EasingStyle.Quad, waitTime)
task.wait(waitTime)
popup:Destroy()
mainText.Text = tonumber(mainText.Text) + ((leaderstats_solved.Value > lastValue) and 1 or -1)
lastValue += ((leaderstats_solved.Value > lastValue) and 1 or -1)
end
function update(newValue : number, isAnimate : boolean)
if isAnimate then
for i = 1, math.abs(newValue - lastValue) do
task.spawn(showPopup)
task.wait(0.1)
end
else
mainText.Text = newValue
lastValue = newValue
end
end
leaderstats_solved.Changed:Connect(function(newValue)
update(newValue, true)
end)
update(leaderstats_solved.Value, false)
how to produce the trace condition?
simply, i must change the value and change again while first changing not done yet, like, changing value to 100, then before its done, change it to 0, its will be something weird, like, being -1, and its calculating like -1 > 0 > -1 > 0, when i ask ai,
i want to get how to force stop a task.spawn. or another alternative maybe help?
any suggestion are very appreciated!