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

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

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

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

1 comment

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

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