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

How to cancel interruptions to tweenservice?

Asked by
v_amp 6
4 years ago

What i mean is, I have a diagonal elevator that works when it's called but when it is spammed, it comes back. I want it so while the tween is playing, the elevator cannot be called back. It functions via keycard (touch).

Here's what i mean: https://gyazo.com/554335dcbb45fbd8e9469c81d01f3479

1
Set up a debounce, while the tween is running, it won't do a thing. User#27525 1 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

What @David0fficial_BR said in the comments, if you need a visual example I can provide one:

local TweenService = game:GetService("TweenService")

local inAction = false
local tweenTime = 10 -- However long you are making the tween

event -- your event / listener
    if not inAction then
        inAction = true

        -- you probably put your if statement in here to see which way to go
        if statement then
            TweenService:Create(obj, TweenInfo.new(tweenTime), {data}):Play()
        else
            TweenService:Create(obj, TweenInfo.new(tweenTime), {data}):Play()
        end

        wait(tweenTime)
        inAction = false
    end
end)

This is only for visual examples, you can copy the format but not the contents of the code since it will not work if you straight up copy paste. Add any other variables / items you need just include the debounce / cooldown.

Ad

Answer this question