So I have a part and I want it to face the mouse position, whats a more effective way to do this.
the script I have:
Spell.CFrame = CFrame.new(Spell.CFrame.p, MouseHitPos)
So I have a part and I want it to face the mouse position, whats a more effective way to do this.
the script I have:
Spell.CFrame = CFrame.new(Spell.CFrame.p, MouseHitPos)
Are you asking if there are any formulas that have the same function as that, although better or your just questioning on how to make it properly face the mouse position since from what I saw in the video the lightning doesnt face the mouse position properly, however this can be fixed by
Spell.CFrame = CFrame.new(Spell.CFrame.p, MouseHitPos) * CFrame.Angles(0,math.rad(45),0) --Keep changing 45 until you get it perfectly.
It looks like it is working, but the front face is on the long side, so try switching up the axis length, or try what is said above.
It works alright, but it’s not perfect is there a way to do it using a ray?
I recommend using a BodyGyro object in the ‘Spell’ and setting said BodyGyro’s CFrame instead of the ‘Spell’, I believe it would be more reliable, and also look better too:
Spell.BodyGyro.CFrame = CFrame.new(Spell.Position, MouseHitPos)
do you mean make it face with ray?
if so then
local ray = Ray.new(YourStick.Position,(mouse.Hit.p - YourStick.Position).unit * 80)
local part,pos = workspace:FindPartOnRayWithIgnoreList(ray,{plr.Character,yourtool},false,false)
lightning.CFrame = CFrame.new(lightning.CFrame,p,mouse.Hit.p)
Not sure how this works but i’ll give it a shot.