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

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

Asked by 5 years ago

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!

0
Are both the tween and the touch event in the same script? Norbunny 555 — 5y

1 answer

Log in to vote
0
Answered by
Launderer 343 Moderation Voter
5 years ago

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
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 :/ Theroofypidgeot 21 — 5y
Ad

Answer this question