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

[Solved] Why does make part tween correctly at first then it starts doing 360s?

Asked by 3 years ago
Edited by greatneil80 3 years ago
local t = game:GetService("TweenService")

local infoOpen = TweenInfo.new(2, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, false, 0)
local goalOpen = {}
goalOpen.Position = script.Parent.DoorRefOpen.Position
goalOpen.Orientation = Vector3.new(0, 90, 0)


local infoClose = TweenInfo.new(2, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut, 0, false, 0)
local goalClose = {}
goalClose.Position = script.Parent.DoorRefClose.Position
goalClose.Orientation = Vector3.new(0, 180, 0)

local g = false

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
    if g == false then
        local d = t:Create(script.Parent.DoorHandle, infoOpen, goalOpen)
        d:Play()
        g = true
    elseif g == true then
        local d = t:Create(script.Parent.DoorHandle, infoClose, goalClose)
        d:Play()
        g = false
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Solved it all I need to do was change line 6 to:

goalOpen.CFrame = script.Parent.DoorHandle.CFrame:ToWorldSpace(CFrame.Angles(0, math.rad(-90), 0))
Ad

Answer this question