#What could be causing the part to rotate while moving in CFrame?

29 messages · Page 1 of 1 (latest)

stone pebble
#

Here's the script:


door = script.Parent.Parent.Parent.Door


local TweenService = game:GetService("TweenService")
local part = script.Parent


local tweenInfo = TweenInfo.new(4.328,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)

local doorOpen = {CFrame = CFrame.new(2.267, 26.5, -238.952)}
local doorClose = {CFrame = CFrame.new(2.267, 18.5, -238.952)}

local Open1 = TweenService:Create(door,tweenInfo,doorOpen)
local Close1 = TweenService:Create(door,tweenInfo,doorClose)


script.Parent.MouseClick:connect(function()

    if open == false then
        Open1:Play()
        script.Parent.Parent.Sound:Play()
        wait(6)
        open = true

    else
        Close1:Play()
        script.Parent.Parent.Sound:Play()
        wait(6)
        open = false
    end
end)```
devout talon
#

It might be the tween

granite mason
#

100% is

#

don't tween the CFrame

#

tween the position

#

also don't wait 6 seconds do

#

Close1.Completed:Wait()

#

it'll wait for it to be completed

stone pebble
#

oh

#

thats better

#

i got this script from a tutorial in yt

#

i got really basic scripting skills

#

what exactly should i do to fix the code?

granite mason
#

uhh

#

instead of doorClose using CFrame

#

since that has rotational data

#

change it to Position

#

and get the closed and open Position

#
local open = false

local door = script.Parent.Parent.Parent.Door


local TweenService = game:GetService("TweenService")
local part = script.Parent


local tweenInfo = TweenInfo.new(4.328,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)

local doorOpen = {Position = Vector3.new(x,y,z)}
local doorClose = {Position = Vector3.new(x2,y2,z2}

local Open1 = TweenService:Create(door,tweenInfo,doorOpen)
local Close1 = TweenService:Create(door,tweenInfo,doorClose)


script.Parent.MouseClick:connect(function()

    if open == false then
        Open1:Play()
        script.Parent.Parent.Sound:Play()
        Open1.Completed:Wait()
        open = true

    else
        Close1:Play()
        Close1.Completed:Wait()

script.Parent.Parent.Sound:Play()
       
        open = false
    end
end)```
#

like that

stone pebble
#

hm

#

i think it will work now

granite mason
#

change x,y,z to whatever position values

#

the open and close are

stone pebble
#

oh boy it worked

#

tysm

granite mason
#

no worries

stone pebble
#

this has been an issue i was unable to find a fix for way too long

#

tysm again