So, I have this GUI connected to a remoteevent that tells it when to change text and pop up But it's super glitchy, and I'm not sure how to do what I'm trying to do. I want it to stay up if it continues to receive events, but to close if it stops. This might be a bad explanation but I'll try to give an example.
GUI receives notification request from event (gui pops up with number) Whilst gui is still up, receives a notification event again (gui number changes instead of it going down after (blabla) seconds* Waits around 1-2 seconds (gui goes down) Around another 1-2 seconds, another notification request (gui pops up w/ number)
and so forth.
This is the code:
game.ReplicatedStorage.sendnotif.OnClientEvent:connect(function(number) local c = script.Parent.n c.Parent = script.Parent c.number.Text = "+"..number c:TweenPosition(UDim2.new(0.438,0,0.85,0), "Out", "Quad", 0.3) wait(.85) c:TweenPosition(UDim2.new(0.438,0,1.2,0), "Out", "Quad", 0.3) end)
You have 2 problems:
Fix:
local call = 0 -- number of times the event has been called game.ReplicatedStorage.sendnotif.OnClientEvent:Connect(function(number) call = call + 1 local startCall = call local c = script.Parent.n c.Parent = script.Parent c.number.Text = "+"..number c:TweenPosition(UDim2.new(0.438,0,0.85,0), "Out", "Quad", 0.3, true) wait(.85) if call ~= startCall then return end -- this means the function has been activated again, so stop c:TweenPosition(UDim2.new(0.438,0,1.2,0), "Out", "Quad", 0.3, true) end)