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

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

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago

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?

0
Script:16: attempt to call a CFrame value. i get that error in local script, how should i do it?? back7776 4 — 4y
0
Getting a Coordinate Frame should always be 'CFrame.new()', NOT 'CFrame()' TheLuminent 1204 — 4y
0
so it should be " if tr.Orientation == CFrame.new(0,90,0)"? or without .Orientation back7776 4 — 4y
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) TheLuminent 1204 — 4y
View all comments (5 more)
0
ok i will try it back7776 4 — 4y
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))' TheLuminent 1204 — 4y
0
yeah it works man thanks alot back7776 4 — 4y
0
Should i use RemoteEvents or RemoteFunctions? back7776 4 — 4y
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? TheLuminent 1204 — 4y
Ad

Answer this question