#ui going too much far back when hovered too fast
1 messages · Page 1 of 1 (latest)
Can you share the script where you play the tween
Debounce could work
how do i add that
The tween won't work until the previous one completed if you add debounce
so what should i do
Like create a variable in the first line of the script and make it false , to make it false when the server created
Then
When touched (i think when the event fired), let it check if the variable for debounce is false or not, return if true because true will mean the tween is working
could u make an example...
And make the variable true
Okay one minute
thank you
-- debounce = false, means the tween is not working, tween is able to work .
-- debounce = true, means the tween is working, another tween can't work right now.
local debounce = false --False when the server created
local tween1 = game.TweenService:Create()
script.Parent.MouseButton1Click:Connect(function()
if debounce == true then --If debounce = true, which means a tween already working, return (return is like stop there, don't move on).
return
end
debounce = true --Since the tween will work, set the debounce true
tween1:Play()
tween1.Completed:Wait() --Wait for the tween to be completed.
debounce = false --Since the tween completed, another tween can work anymore.
end)
With photo, if it will be easier for you
@chilly musk can u add that to my script i cant do it rn sry
local TweenService = game:GetService("TweenService")
game.ReplicatedStorage.SellGuiEvent.OnClientEvent:Connect(function()
local button = script.Parent
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://6895079853"
sound.Volume = 10
sound.Parent = button
sound.Looped = false
sound:Play()
button.Visible = true
button.Size = UDim2.new(0, 0, 0, 0)
local targetSize = UDim2.new(0.274, 0, 0.043, 0)
local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Back, Enum.EasingDirection.Out)
local tween = TweenService:Create(button, tweenInfo, {Size = targetSize})
tween:Play()
end)```