So I have this script right here:
local tool = script.Parent
local toolName = script.Parent.Name
local clickEvent = tool.ClickEvent
local clickEventConnection
local player = game.Players.LocalPlayer
local character = player.Character
local head = character.Head
local partFinder = true
local function createPart()
if partFinder == true then
local fireball = Instance.new('Part')
fireball.Name = "magic1"
fireball.Transparency = 1
fireball.Shape = "Ball"
#fireball.Size = Vector3.new(2, 2, 2)
fireball.CanCollide = false
fireball.Anchored = true
fireball.CFrame = head.CFrame
fireball.Velocity = head.CFrame.lookVector*50
fireball.TopSurface = "Smooth"
fireball.BottomSurface = "Smooth"
local fire = Instance.new("Fire")
fire.Parent = fireball
fireball.Parent = workspace
local copy = script.Parent.DamageScript:Clone()
copy.Parent = fireball
local copy2 = script.Parent.Damage:Clone()
copy2.Parent = fireball
partFinder = false
local headRotation = head.Orientation.X
for i = 1,50 do
fireball.CFrame = CFrame.new(fireball.Position + Vector3.new(0, 0, -0.2), Vector3.new(lookVector, 0, 0))
wait(0.1)
end
wait(5)
partFinder = true
fireball:Destroy()
end
end
local function onClick(player)
createPart(head)
end
local function onEquip()
clickEventConnection = clickEvent.OnServerEvent:connect(onClick)
end
local function onUnequip()
clickEventConnection:disconnect()
end
tool.Equipped:connect(onEquip)
tool.Unequipped:connect(onUnequip)
And I need to make the fireball go in the same direction as I'm facing.
Is there away to use CFrame to do it?
Problem Piece:
local headRotation = head.Orientation.X
for i = 1,50 do
fireball.CFrame = CFrame.new(fireball.Position + Vector3.new(0, 0, -0.2), Vector3.new(lookVector, 0, 0))
wait(0.1)
end |