Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to cancel interruptions to tweenservice?

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 comment

1

Set up a debounce, while the tween is running, it won't do a thing.

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.