Is there an angle/orientation or a property that handles part's 'Forward' side?

  1. What do you want to achieve? Keep it simple and clear!
    When a player touches a trigger, another game object is created, and its position and orientation is dependent on another part’s CFrame but then it has its position modified to move forward depending on where it’s facing
  2. What is the issue? Include screenshots / videos if possible!
    I’m looking for a property or a calculation of some sort to tell the part exactly where this forward facing side is, but I’m struggling to figure out how this would be done,

I could just create 4 different scripts for 4 different 90 degree facing sides and incorporate a static angle at which the object should travel at before being removed, but I’d like this automated if possible so it knows exactly which way to ‘move’ the object.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I couldn’t find an angle that would do this in the CFrame documentation or any built-in property for a part.

This is the code I’ve written that will work for one of those occasions:

local serverStorage = game:GetService("ServerStorage")
local arrow = script.Parent.Damage


for count = 45, 0, -1 do -- how many times to run the code
	arrow.Position += Vector3.new(2,0,0) -- new position of the object
	task.wait(0.00005) -- controls the 'smoothness' of the movement
end

arrow.Parent:Destroy() --destroys the entire arrow model, including it's scripts

So this script will effectively move the object 45 times in a fixed direction and destroy itself at the end, to put this into a scenario, here’s a trap I’ve made that is meant to spawn an arrow in the position and orientation of the ‘black’ part:
image
Which it does, I am using the orientation value of the black part to determine the arrow’s orientation:
image
But as you can see by the code, this will only work when I need the arrow to travel on the positive X axis, if I was to rotate the trap model 180 degrees, I’d need the arrows to travel on the negative X axis.

I’d rather avoid dozens of else ifs in the code as well, please let me know if anyone has any ideas. I am quite new to angles and CFrame manipulation in roblox so I’m happy to be butchered a bit with lore or if I’m missing something obvious here.

The CFrame.LookVector property might be what you’re looking for.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.