Im trying to make a Script where the part rotates while curving around a part but the rotating is being stupid
local TS = game:GetService("TweenService")
local rarm = workspace.arm
local root = workspace.rot
rarm.Transparency = 0.7
rarm.Orientation = Vector3.new(45, 0.09, -19.88)
rarm:ClearAllChildren()
rarm.Anchored = true
rarm.Position = root.Position + Vector3.new(-3, -3, 2)
function lerp(a, b, t)
return a + (b - a) * t
end
function cubicBezier(t, p0, p1, p2, p3)
local l1 = lerp(p0, p1, t)
local l2 = lerp(p1, p2, t)
local l3 = lerp(p2, p3, t)
local a = lerp(l1, l2, t)
local b = lerp(l2, l3, t)
local cubic = lerp(a, b, t)
return cubic
end
local f1 = root.Position + -root.CFrame.LookVector*2 + -root.CFrame.upVector*3 + -root.CFrame.RightVector*3
local f2 = root.Position + root.Position + root.CFrame.LookVector*.8 + -root.CFrame.upVector*.15 + -root.CFrame.RightVector*5.5
local f3 = root.Position + root.CFrame.LookVector*5.25 + root.CFrame.upVector*.5 + -root.CFrame.RightVector*2.75
local f4 = root.Position + root.CFrame.LookVector*7.5 + root.CFrame.upVector*1.3 + root.CFrame.RightVector*1.5
spawn(function()
for t = 0,1,.08 do
local curve = cubicBezier(t,f1,f2,f3,f4)
rarm.CFrame = CFrame.new(curve)
rarm.Orientation = rarm.Orientation + Vector3.new(0,0,5)
game:GetService("RunService").Heartbeat:Wait()
end;
end)
this my code

1 comment
Something like this?