#ui going too much far back when hovered too fast

1 messages · Page 1 of 1 (latest)

glacial marlin
#

@chilly musk u mean in the buttons scripts?

chilly musk
glacial marlin
chilly musk
#

Debounce could work

glacial marlin
#

how do i add that

chilly musk
#

The tween won't work until the previous one completed if you add debounce

glacial marlin
#

so what should i do

chilly musk
#

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

glacial marlin
#

could u make an example...

chilly musk
#

Okay one minute

glacial marlin
#

thank you

chilly musk
#
-- 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

glacial marlin
#

@chilly musk can u add that to my script i cant do it rn sry

chilly musk
#

Alr if you share the script

#

With copy paste

glacial marlin
#
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)```