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
)
local door1Open = {CFrame = CFrame.new(82.82, 4.693, 80.553)} lcal door2Open = {CFrame = CFrame.new(82.82, 4.693, 62.559)} local door1Close = {CFrame = CFrame.new(82.82, 4.693, 74.707)} local door2Close = {CFrame = CFrame.new(82.82, 4.693, 68.511)} local tween1open = TweenService:Create(door1,tweeningInformation,door1Open) local tween1close = TweenService:Create(door1,tweeningInformation,door1Close) local tween2open = TweenService:Create(door2,tweeningInformation,door2Open) local tween2close = TweenService:Create(door2,tweeningInformation,door2Close) script.Parent.Detector1.Touched:Connect(function(hit) tween1open:Play() tween2open:Play() wait(2) tween1close:Play() tween2close:Play() end) script.Parent.Detector2.Touched:Connect(function(hit) tween1open:Play() tween2open:Play() wait(2) tween1close:Play() tween2close:Play() end)
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
local Debounce = true script.Parent.Detector1.Touched:Connect(function(hit) if hit.Parent:findFirstChild("Humanoid") and Debounce then Debounce = false tween1open:Play() tween2open:Play() wait(2) tween1close:Play() tween2close:Play() Debounce = true end end)
'