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

Why do objects behave so weird when I'm tweening them?

Hello there, I'm trying to work with tweens, and it's coming along pretty well, I only have 1 problem:

Objects behave very weird when I put a touch script in them, whili I'm tweening them.

I'm a learning scripting but I don't know what I've done wrong, when the object is being tweened with a touch script inside of it, it immediately stops the tween if it touches a part, or randomly glitches above a part

(With touch script I mean something like this:

script.Parent.Touched:Connect(function()

print("Hello world!")

end)

)

Anyway, does someone know what I've done wrong, and how I could fix this, thanks for your help! And sorry for my bad English, I'm Dutch myself and my English is pretty bad!

1 comment

0

Are both the tween and the touch event in the same script?

1 answer

It's probably playing multiple times on the touch due to a lack of debounce.

local debounce = false
local delay = 3 -- how much time between touches.

script.Parent.Touched:Connect(function()
	if debounce ~= true then
		debounce == true
		
		print("Hello world!")

		wait(delay)
		debounce = false
	end
end

1 comment

0

No, that's not it, I've added debounce. The object that is being tweened just stops the tween and turns cancollide on when it touches a part :/

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