I am currently working on a stage lighting system. I have a script that does work but I need to calculate the difference between the current position and then new position which makes it difficult. I was wondering if anyone would be able to help me make it so that I can just type in a position and then it rotates until it gets to that point.

    on = false

local tilt = script.Parent.Parent.Parent

Increment = 180

  

workspace.activateSpots.ClickDetector.MouseClick:Connect(function()

if on == false then

on = true

for C = 1, Increment do

wait()

tilt.PrimaryPart = tilt.hinge

tilt:SetPrimaryPartCFrame(tilt.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0,math.rad(21/Increment),0))

end

elseif on == true then

on = false

for C = 1, Increment do

wait()

tilt.PrimaryPart = tilt.hinge

tilt:SetPrimaryPartCFrame(tilt.PrimaryPart.CFrame * CFrame.fromEulerAnglesXYZ(0,math.rad(-21/Increment),0))

end

end

end)

2 comments

0

Wdym by "Type in a position"?

0

I meant like so that you type 90,-45,90 and it rotates to that position.