With the help of a friend, I have a script for a fireball that works pretty well- it does damage upon hitting a humanoid, burns them for a set amount of seconds (dealing more damage) and even has a little explosion when it hits a solid object. However, as you can see here...

https://gfycat.com/TightUnselfishCurlew

My fireball launches a good amount over the head of the player, and dips down. I don't want it to dip down, I want it to move in a straight line towards the direction I click. How could I do this? Here is my code:

local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local fire = script:WaitForChild("Fire")
local cooldown = false

local speed = 150
local damage = 50
local cd = 1 -- cooldown (seconds)
local burntime = 4 --(seconds)
 
tool.Activated:connect(function()
	if not cooldown then
		cooldown = true
		local pos = mouse.Hit.p
		
		local ball = Instance.new("Part", workspace)
		ball.Shape = "Ball"
		ball.TopSurface = "Smooth"
		ball.BottomSurface = "Smooth"
		ball.Size = Vector3.new(5, 5, 5)
		ball.Position = tool.Handle.Position
		ball.CanCollide = false
		ball.Transparency = 1
		ball.BrickColor = BrickColor.new("Neon orange")
		fire:Clone().Parent = ball
		ball.Fire.Enabled = true
		
		local direction = (tool:WaitForChild("Handle").Position - pos).Unit
		ball.Velocity = direction * -speed
		
		wait(.05)
		
		ball.CanCollide = true
		
		game:GetService("Debris"):AddItem(ball, 10)
		
		ball.Touched:connect(function(part)
			
			local exp = Instance.new("Explosion", workspace)
			exp.Position = ball.Position + ball.CFrame.lookVector * ball.Size
			exp.DestroyJointRadiusPercent = 0
			exp.BlastRadius = 0
			exp.BlastPressure = 0
			
			ball:Destroy()
			--other stuff
			if part.Parent:FindFirstChild("Humanoid") then
				local h = part.Parent:FindFirstChild("Humanoid")
				
				coroutine.resume(coroutine.create(function()
					local f = fire:Clone()
					f.Parent = h.Parent.Torso
					f.Enabled = true
					for i = 1, burntime do
						if h.Parent:FindFirstChild("Torso") then
							print("burn")
							h:TakeDamage(damage/burntime)
							wait(1)
						end
					end
					if f then f.Enabled = false wait(1) f:Destroy() end
				end))
				
				if h.Parent:FindFirstChild("Torso") then
					h.Parent.Torso.Velocity = Vector3.new(0, 0, 0)
				end
			end
		end)
		
		coroutine.resume(coroutine.create(function()
			wait(cd)
			cooldown = false
		end))
		
		while ball and wait() do
			ball.Velocity = direction * -speed
		end
		
		
		
	end
	
	
end)

1 comment

0

This is more of a grenade-type script. You have to anchor the projectile then use CFrame for positioning instead of Velocity. The only way I know to avoid the "dip".