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

how do I constantly change the direction of a ray with a loop and my mouse?

Asked by 4 years ago

Code:

local ray = Ray.new(char.HumanoidRootPart.CFrame.p, mouse.p)


while true do
    wait()
    trident.CFrame = char.HumanoidRootPart.CFrame*CFrame.new(0,2.5,0)
    trident.CFrame = CFrame.new(trident.CFrame.p  ,  ray.Direction)*CFrame.Angles(0,math.rad(180),0)
end

I tried to make this trident constantly point where my mouse was pointing before I launch it. The problem here is that when I fire the command, it would only constantly point at the last thing I pointed at, not where my mouse is currently. How do I fix this?

0
Put the ray into the while loop. This will fix it because you are updating the mouse's position and humanoidrootpart's position. XviperIink 428 — 4y
0
I already tried that, didn't work xXKingCool258Xx 39 — 4y

Answer this question