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

Why is TweenService weirdly rotating?

Asked by 5 years ago
Edited 5 years ago

Hello! I am new to TweenService and I had some issues. Can someone help me with it?

My Part makes a weird 90° turn. Why is that? I have no line of code changing the rotation.

Here is a short video of it: https://gyazo.com/f74e2d439fae96d90d76d1c5c6a9aa58

I hope someone can help! Have a nice day!

My script:

local TweenService = game:GetService("TweenService") local door1 = script.Parent.DoorLeft:WaitForChild("Union") local door2 = script.Parent.DoorRight:WaitForChild("Union") local door12 = script.Parent.DoorLeft:WaitForChild("Part") local door12 = script.Parent.DoorRight:WaitForChild("four") local tweeningInformation = TweenInfo.new( 0.5,
Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0 )

01local door1Open = {CFrame = CFrame.new(82.82, 4.693, 80.553)}
02lcal door2Open = {CFrame = CFrame.new(82.82, 4.693, 62.559)}
03local door1Close = {CFrame = CFrame.new(82.82, 4.693, 74.707)}
04local door2Close = {CFrame = CFrame.new(82.82, 4.693, 68.511)}
05local tween1open = TweenService:Create(door1,tweeningInformation,door1Open)
06local tween1close = TweenService:Create(door1,tweeningInformation,door1Close)
07local tween2open = TweenService:Create(door2,tweeningInformation,door2Open)
08local tween2close = TweenService:Create(door2,tweeningInformation,door2Close)
09 
10script.Parent.Detector1.Touched:Connect(function(hit)
11    tween1open:Play()
12    tween2open:Play()
13    wait(2)
14    tween1close:Play()
15    tween2close:Play()
View all 23 lines...
0
Pls put this in a code block by using ``` Code here ``` IcyMizu 122 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago

It is because you didn't add a debounce and also you didn't check if the part touched is a character and it keeps hitting the door and it's running the tween again and again and it keeps moving, debounce is a bool which stop code from repeatedly running

See more here: Debounce

so you can try and put this in the code

01local Debounce = true
02script.Parent.Detector1.Touched:Connect(function(hit)
03    if hit.Parent:findFirstChild("Humanoid") and Debounce then
04        Debounce = false
05        tween1open:Play()
06        tween2open:Play()
07        wait(2)
08        tween1close:Play()
09        tween2close:Play()
10        Debounce = true
11    end
12end)

'

0
It still rotates for some reason, ggAmazingMan 32 — 5y
Ad

Answer this question