I’m trying to make a beam that when it appears, goes towards the cursor (does not follow once spawned) and rotates on its Y axis multiples times before dissapearing. The part has child parts welded using WeldConstraints, so i have to use CFrames to reposition it.
I can easily make the beam move towards the destination position, but whenever i add the rotation factor, everything breaks. The beam either
- Goes to 0,0,0
- Rotates itself relative to the world towards 0,90,0
- Changes trajectory by 90 to its right
- Rotates only 90 degrees
As of now, this is what i have written:
sword.CFrame = CFrame.new(hrp.Position + hrp.CFrame.LookVector * 3, MouseP)
local repeatcount = 4
local pos = sword.CFrame.LookVector*100/repeatcount
for i = 1, repeatcount do
local tween = game:GetService("TweenService"):Create(sword, TweenInfo.new(1.4/repeatcount, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {CFrame = CFrame.new(sword.Position+pos)*CFrame.Angles(0,sword.CFrame.Rotation.Y+math.rad(90),0)})
tween:Play()
tween.Completed:Wait()
end
This specific code gives me the 3 last problems, all at once. I have not a single idea how i can fix it.
Please take into account the fact i need both the Position and Rotation in CFrames. I cannot find any answers taking every criteria into account on this forum. Thank you.