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

How do I make a cloned object constantly face where my mouse is pointing?(More info in desc)

Asked by 4 years ago

Code:

while true do
    wait()
    local ray = Ray.new(char.HumanoidRootPart.CFrame.p, (mouse.p - char.Head.CFrame.p).Unit)
    trident.CFrame = char.Head.CFrame*CFrame.new(0,2.5,0)
    trident.CFrame = trident.CFrame*CFrame.Angles(math.rad(0),math.rad(0),math.rad(0))
end

In these lines of code I tried using CFrame.Angles to make the pointy part of my spear always face where my mouse is pointing. but the

trident.CFrame = trident.CFrame*CFrame.Angles(math.rad(0),math.rad(0),math.rad(0))

part is where it got tricky. I used ray.Direction but it won't accept it because it needs a number value, not a Vector3 value. How do I make it so that it would constantly face my mouse?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

ok its very easy if you know the trick if you use something like this

trident.CFrame = CFrame.new(trident.CFrame.p  ,  mouse.p)

but this only works if the pointy part is in the front

0
Thanks for trying to answer, I tried this and yep, it faced the pointy part forward. It won't constantly do it, though. Even if I place it in a loop xXKingCool258Xx 39 — 4y
Ad

Answer this question