Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i get the orientation of the mouse.hit?

so im trying to make a portal gun and i need to get the part orientation that the mouse is aiming at so i can rotate the portal depending on the orientation of the walls heres what i've tried so far:

script.Parent.hit.OnServerInvoke = function(player,hitp)
	workspace.Blue.CFrame = hitp
	workspace.Blue.Orientation = Vector3.new(0, 0, 0)
	print("blue")
	end
script.Parent.hit2.OnServerInvoke = function(player,hitp)
	workspace.Red.CFrame = hitp
	workspace.Red.Orientation = Vector3.new(0, 0, -90)
	if hitp.Orientation.Y == 90 then
	workspace.Red.Orientation = Vector3.new(0, 90, -90)
	print("Red")
	end
end

but mouse.hit is a cframe so that doesnt work i even tried changing what is in if to

if hitp == CFrame(0,90,0) then

end

and too putting CFrame.new

1 answer

✓ Accepted answer

I don't think you can get the orientation of the mouse's hit, instead use Mouse.Target and get the orientation of the target maybe?

9 comments

0

Script:16: attempt to call a CFrame value. i get that error in local script, how should i do it??

0

Getting a Coordinate Frame should always be 'CFrame.new()', NOT 'CFrame()'

0

so it should be " if tr.Orientation == CFrame.new(0,90,0)"? or without .Orientation

0

Orientation should be in Vector3.new(x,y,z), if you want to set it all by CFrame you can do CFrame.new(x,y,z) * CFrame.Angles(x,y,z)

0

ok i will try it

0

When you set the orientation of the portal, try this. 'Mouse.Hit.CFrame * CFrame.Angles(math.rad(Mouse.Target.Orientation.X),math.rad(Mouse.Target.Orientation.Y),math.rad(Mouse.Target.Orientation.Z))'

0

yeah it works man thanks alot

0

Should i use RemoteEvents or RemoteFunctions?

0

RemoteEvents to pass information, RemoteFunctions to get information from either the server or the client. Could you also mark my response as the answer so that I get the rep and so that nobody tries to answer?

This discussion is preserved as it was. New answers, comments, and votes are closed.