However, I simply don’t know how. It kept spawning facing in one direction (see picture 1).
Thank you in advance for helping me!
I will leave you with my script(serverscript)
Shard.Orientation = Vector3.new(0,player.Character.HumanoidRootPart.CFrame.LookVector,90) --90 so that the part wouldn't go upside down
--my problem is at Y axis, since it was the axis that changes the facing direction
You might try using the Roblox Tools system to do this. When the tool is equipped, it will automatically be welded to the player using a grip that you can define as being directly in front.
One thing I noticed about your script, is that you’re setting the Orientation, which is expressed in radians, using a value of 90, which is in degrees. Maybe try using math.pi instead. And actually, I think Orientation is not settable, as it’s a sub-property of the part’s CFrame.
Maybe try something like:
-- a cframe 3 studs in front of the character
local ShardCF = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -3)
-- fix the shard's orientation
Shard.CFrame = ShardCF * CFrame.fromOrientation(math.pi/2, 0, 0)