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

How to refer to just one orientation axis. ???

Asked by 5 years ago

I am curious how to say if just one orientation axis is a certain number. do you use underscores for the other axises?

0
function onClicked() if script.Parent.Union.Orientation == 0,0,2 then print("hello world") end end script.Parent.ClickDetector.MouseClick:connect(onClicked) PaliKai13 92 — 5y
0
could the 0s be replaced with something, or is there a way to just reference one asix? PaliKai13 92 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
function onClicked()
    if script.Parent.Union.Orientation.Z == 2 then
        print('Hello World!')
    end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

Orientation is a Vector3 value, so it has X,Y,Z,Magnitude, and unit (not sure about unit) using == 2 will not work if Orientation.Z == 2.1 so you can round the rotation before

local function round(val)
    return math.floor(val+0.5)
end
function onClicked()
    if round(script.Parent.Union.Orientation.Z) == 2 then
        print('Hello World!')
    end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
0
thx adasgadfg! PaliKai13 92 — 5y
0
ok, one more question, is there a way to SET just the z axis orientation? PaliKai13 92 — 5y
0
part.Orientation = Vector3.new(part.Orientation.X,Part.Orientation.Y,2) User#25606 0 — 5y
Ad

Answer this question