Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i go about making a debounce for this code?

Asked by
Fxicity 10
3 years ago
script.Parent.MouseButton1Click:Connect(function()

    local tweenService = game:GetService("TweenService")
    local Properties = {
        Position = Vector3.new(-15.5, 1, 42.5)  
    }
    local tweenInfo = TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
    local tween = tweenService:Create(game.Workspace.MoneyGiver,tweenInfo,Properties)

    tween:Play()

    wait(3.5)

    local tweenService = game:GetService("TweenService")
    local Properties = {
        Position = Vector3.new(-15.5, -17, 42.5)    
    }
    local tweenInfo = TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
    local tween = tweenService:Create(game.Workspace.MoneyGiver,tweenInfo,Properties)

    tween:Play()
end)

I want it so that you click a surfacegui, no clickdetector, and theres a cooldown before the next script.

1 answer

Log in to vote
0
Answered by
imacodr 40
3 years ago

Just add a simple wait()

local debounce = true
script.Parent.MouseButton1Click:Connect(function()

if debounce = true then
    debounce = false
    local tweenService = game:GetService("TweenService")
    local Properties = {
        Position = Vector3.new(-15.5, 1, 42.5)  
    }
    local tweenInfo = TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)
    local tween = tweenService:Create(game.Workspace.MoneyGiver,tweenInfo,Properties)

    tween:Play()

wait(3.5)
debounce = true
end

end)
Ad

Answer this question