I need to make a script that about of rotating a model , because ı just added a proximity prompt to my door model but ı need a opening animation , ı just wanted to do it with rotating.
If you get a idea please reply to this topic.
If it’s a model then you need to use:SetPrimaryPartCFrame to move the entire model. Make sure to set a primary part for the model, also you might have to change it slightly, maybe change the position of the door too.
local door = --define door
local function openDoor()
for i = 1, 30 do
wait()
door:SetPrimaryPartCFrame(door.PrimaryPart.CFrame * CFrame.Angles(0, math.rad( 3),0)
end
end
local function closeDoor()
for i = 1, 30 do
wait()
door:SetPrimaryPartCFrame(door.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-3),0)
end
end
--Just For testing
while wait(3) do
openDoor()
wait(3)
closeDoor()
end
4 Likes
You need to apply a cframe offset and the size of the axis of the door you are rotating on so it can rotate around a part. like
door.CFrame = pivot.CFrame * CFrame.Angles(0, math.rad(t), 0) * CFrame.new(0,door.Size.Y, 0)
where t is the alpha of our interpolation
2 Likes
can ı put this script in to the proximity prompts script,
Just Call the function when they use the prompt. Also the primary part should be the “hinge” part. The hinge part can be an invisible part that is where the door should swing.