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

Orientation on click part?

Asked by 3 years ago

Hi, I made a script, if the player clicks on a part, the part's orientation will get rotated with 15° degrees. But how do I repeat it? I mean when the Orientation reaches the Vector3.new(0,0,0) again, then the player can't rotate the part anymore.

local clickdetector = script.Parent.Parent.ClickDetector
local part0 = script.Parent.Parent.Parent.Part0

clickdetector.MouseClick:Connect(function()
    if part0.Orientation == Vector3.new(0,0,0) then
        part0.Orientation = Vector3.new(0,0,-15)
    elseif part0.Orientation == Vector3.new(0,0,-15) then
        part0.Orientation = Vector3.new(0,0,-30)
    elseif part0.Orientation == Vector3.new(0,0,-30) then
        part0.Orientation = Vector3.new(0,0,-45)
    elseif part0.Orientation == Vector3.new(0,0,-45) then
        part0.Orientation = Vector3.new(0,0,-60)
    elseif part0.Orientation == Vector3.new(0,0,-60) then
        part0.Orientation = Vector3.new(0,0,-75)
    elseif part0.Orientation == Vector3.new(0,0,-75) then
        part0.Orientation = Vector3.new(0,0,-90)
    elseif part0.Orientation == Vector3.new(0,0,-90) then
        part0.Orientation = Vector3.new(0,0,-105)
    elseif part0.Orientation == Vector3.new(0,0,-105) then
        part0.Orientation = Vector3.new(0,0,-120)
    elseif part0.Orientation == Vector3.new(0,0,-120) then
        part0.Orientation = Vector3.new(0,0,-135)
    elseif part0.Orientation == Vector3.new(0,0,-135) then
        part0.Orientation = Vector3.new(0,0,-150)
    elseif part0.Orientation == Vector3.new(0,0,-150) then
        part0.Orientation = Vector3.new(0,0,-165)
    elseif part0.Orientation == Vector3.new(0,0,-165) then
        part0.Orientation = Vector3.new(0,0,180)
    elseif part0.Orientation == Vector3.new(0,0,180) then
        part0.Orientation = Vector3.new(0,0,165)
    elseif part0.Orientation == Vector3.new(0,0,165) then
        part0.Orientation = Vector3.new(0,0,150)
    elseif part0.Orientation == Vector3.new(0,0,150) then
        part0.Orientation = Vector3.new(0,0,135)
    elseif part0.Orientation == Vector3.new(0,0,135) then
        part0.Orientation = Vector3.new(0,0,120)
    elseif part0.Orientation == Vector3.new(0,0,120) then
        part0.Orientation = Vector3.new(0,0,105)
    elseif part0.Orientation == Vector3.new(0,0,105) then
        part0.Orientation = Vector3.new(0,0,90)
    elseif part0.Orientation == Vector3.new(0,0,90) then
        part0.Orientation = Vector3.new(0,0,75)
    elseif part0.Orientation == Vector3.new(0,0,75) then
        part0.Orientation = Vector3.new(0,0,60)
    elseif part0.Orientation == Vector3.new(0,0,60) then
        part0.Orientation = Vector3.new(0,0,45)
    elseif part0.Orientation == Vector3.new(0,0,45) then
        part0.Orientation = Vector3.new(0,0,30)
    elseif part0.Orientation == Vector3.new(0,0,30) then
        part0.Orientation = Vector3.new(0,0,15)
    elseif part0.Orientation == Vector3.new(0,0,15) then
        part0.Orientation = Vector3.new(0,0,0)
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Try this:

clickdetector.MouseClick:Connect(function()
part0.Orientation = part0.Orientation + Vector3.new(0,15,0)
end)
0
Thank you, SimulatedMath! :) Mimas18Hun 0 — 3y
Ad

Answer this question