The main area of focus is round line 24. I've looked at many sources, but I still need help. So, I have A script that works great, but I need help getting the direction right. The fireball seems to go in one direction no matter which way it is facing. the script is below.
local Tool = script.Parent local Handle = Tool:FindFirstChild("Handle") local FireBallPart = game.ServerStorage:FindFirstChild("Union") local enabled = true local function Shoot(target) if enabled == true then enabled = false local Ball = FireBallPart:Clone() local startPosition = Handle.Position local targetPosition = workspace.Part.position Ball.Parent = workspace Ball.CanCollide = true Ball.Anchored = false local BallCframe = CFrame.new(startPosition) + Vector3.new(.1,1,.1) Ball.CFrame = BallCframe Ball.CFrame = CFrame.new(Ball.Position,targetPosition) local BodyVelocity = Instance.new("BodyVelocity") BodyVelocity.velocity = BallCframe.lookVector * 10 BodyVelocity.Parent = Ball print (BallCframe.lookVector) wait(1) enabled = true wait(50) Ball:Remove() end
For testing, I just wanted it to go towards on part, but that didn't seem to work either.
You'll want to get the mouse by using a RemoteEvent from the client (recommend putting the tools remotes inside of a folder thats in the tool)
LocalScript
local Tool = script.Parent local Remotes = Tool.Remotes local player = game.Players.LocalPlayer local mouse = player:GetMouse() Tool.Activated:Connect(function() Remotes.Shoot:FireServer(mouse.Hit) end)
ServerScript
local Tool = script.Parent local Handle = Tool:FindFirstChild("Handle") local FireBallPart = game.ServerStorage:FindFirstChild("Union") local enabled = true local function Shoot(player,mouse) if enabled == true then enabled = false local Ball = FireBallPart:Clone() local startPosition = Handle.Position local targetPosition = workspace.Part.position Ball.Parent = workspace Ball.CanCollide = true Ball.Anchored = false local BallCframe = CFrame.new(startPosition) + Vector3.new(.1,1,.1) Ball.CFrame = BallCframe Ball.CFrame = CFrame.new(Ball.Position,targetPosition) local BodyVelocity = Instance.new("BodyVelocity") BodyVelocity.velocity = mouse.LookVector * 90 --Speed BodyVelocity.Parent = Ball print (BallCframe.lookVector) wait(1) enabled = true wait(50) Ball:Remove() end
Hope this helps!