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

How can i make a model pivot around a point?

Asked by
Simnico99 206 Moderation Voter
7 years ago

I tried this and its dragging it away instead of rotating it :\

local pivot = CFrame.new()
local part = script.Parent.Door.PrimaryPart
local offset = part.CFrame:toObjectSpace(pivot):inverse() 
local initialRotation = part.CFrame - part.CFrame.p

wait(1)

local firstTick = tick()
local elapsed = 0
local speed = 16
local desiredAngle = 30
local duration = desiredAngle/speed


while elapsed <= duration do
    wait()
    local alpha = math.min(1, elapsed/duration)
    local angle = desiredAngle*alpha
    part.CFrame =CFrame.new(pivot*initialRotation*Vector3.new(angle))*offset
    elapsed = tick() - firstTick
end
0
Not working Simnico99 206 — 7y

Answer this question