#How to RESET the ROTATION of a part?

1 messages · Page 1 of 1 (latest)

wet egret
#

I was trying to make this door model for my horror game, but I didn't figure it out how to reset the rotation of the door.

dense mauve
#

is this ur first time scripting😭

#

"==" is to compare not to set a value btw

#

and you cant just set rotation like that

#

I would save the old cframe in a variable and set the cframe to the variable

#

assuming ".PrimaryPart" is a hinge I would make this:

local TS = game:GetService("TweenService")

local OldFrame = Frame.PrimaryPart.CFrame
local OpenFrame = OldFrame * CFrame.Angles(0,math.rad(-90),0)

local DoorInfo = TweenInfo.new(1, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)

local OpenTweeen = TS:Create(Frame.PrimaryPart, DoorInfo, {CFrame = OpenFrame})
local CloseTweeen = TS:Create(Frame.PrimaryPart, DoorInfo, {CFrame = OldFrame})
#

I typed this str8 into dc so idk if its workin

rare berry
#

theres a toturial on youtube too

wet egret
#

im like 1 year of this

#

i just did this == bcz i was running out of options

dense mauve
#

when ur so desperate you just try everthing lol

wet egret
rare berry
#

watch a toturial like the 5 min one like first search result

sly sandal
# wet egret I was trying to make this door model for my horror game, but I didn't figure it ...

You should save the CFrame of the door before anything so you can revert back to that:

local Door: Model = "path-to-door"
local DoorOriginCFrame: CFrame = Door.PrimaryPart.CFrame

local Tweenfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)

local TweenOpen = TweenService:Create(Door.PrimaryPart, Tweenfo, { CFrame = Door.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(90), 0) })

TweenOpen:Play()

task.wait(4)

local TweenClose = TweenService:Create(Door.PrimaryPart, Tweenfo, { CFrame = DoorOriginCFrame })
TweenClose:Play()

-- If you add your door model into the door variable, and it has a primarypart that works properly, this should work to properly open and close your door. (only visually)

-- I'm not sure if it will turn on the right axis or direction, since I'm just guessing. You can change the CFrame.Angles to change the rotation.
cyan nymph
#

reset

#

with tween

#

theres a property

#

at the param

#

whether to go back to the old form or not

#

so

#

you can also use tween.completed

#

and store the old angle

#

then set it back