I'm making a harry potter wand module and basically I want it to go in a zigzag path, instead of a straight line https://gyazo.com/0ecb8202f4121e86416f9424c754d718. This is my current script
local SpellPart = script.Assets.Projectile:Clone()
SpellPart.Anchored = true
SpellPart.Parent = game.Workspace.Spells
SpellPart.Position = Char.Wand.Effect.Position
SpellPart.CanCollide = false
SpellPart.CFrame = CFrame.new(SpellPart.Position,Char.MouseTarget.Value)
SpellPart.Trails.BaseTrail.Enabled = true
SpellPart.Trails.BaseTrail.Color = ColorSequence.new(Properties.Color)
SpellPart.Trails.OuterTrail.Enabled = true
SpellPart.Trails.OuterTrail.Color = ColorSequence.new(Properties.Color)
local IgnoreList = {Char,SpellPart,Char.Wand.Effect,Char.Wand.Handle}
local SpellSpeed = Properties.Speed/15
Spell = nil --DISABLE SPELL
for Movement = 1, math.huge do
if not SpellPart then break end
wait()
local SpellRay = Ray.new(SpellPart.Position, SpellPart.CFrame.LookVector * SpellSpeed)
local hit,hitpos,hitnormal = workspace:FindPartOnRayWithIgnoreList(SpellRay, IgnoreList,false,true)
if not hit then
SpellPart.CFrame = SpellPart.CFrame + SpellPart.CFrame.LookVector * SpellSpeed
else
SpellPart:Destroy()
break
end
end
end
end
I tried changing the
if not hit then
SpellPart.CFrame = SpellPart.CFrame + SpellPart.CFrame.LookVector * SpellSpeed
to
if not hit then
SpellPart.CFrame = SpellPart.CFrame + SpellPart.CFrame.LookVector * SpellSpeed
SpellPart.CFrame = SpellPart.CFrame + Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1)
But it ended up not hitting at the right spot. Any ideas what I can do?
