Fireball won't deal damage [Solved]

  1. What do you want to achieve? Keep it simple and clear!
    I want to make the fireball deal damage.

  2. What is the issue? Include screenshots / videos if possible!
    The fireball won’t deal damage to players and the fireball sometimes hits the vfx or the hitbox.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    idk i tried changing the first lines of the touched event and no i didn’t look for solutions on the developer hub

Local Script:

-- local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local mouse = player:GetMouse()
local RS = game:GetService("ReplicatedStorage")
local FireBallRemote = RS:WaitForChild("Fireball")
local ThrowAnim = humanoid:LoadAnimation(script.Throw)

local maxthrows = 10
local throws = 10
local throwing = false
local debounce = false

UIS.InputBegan:Connect(function(key,Chatting)
	if key.KeyCode == Enum.KeyCode.Q and not Chatting and not debounce then
		debounce = true
		throwing = true
		repeat
			task.wait(.2)
			FireBallRemote:FireServer(mouse.Hit.p, mouse.Hit.LookVector)
			ThrowAnim:Play()
			throws = throws - 1
		until throws == 0
		if throws == 0 then
			throwing = false
			throws = maxthrows
		end
		task.wait(3)
		debounce = false
	end
end)

Server Script:

local RS = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local FireBall = ServerStorage:FindFirstChild("FireBall")
local FireBallRemote = RS:WaitForChild("Fireball")
local TweenService = game:GetService("TweenService")
local ExplosionVFX = script.ExplosionVFX
local ExplosionSound = RS.Sounds.Explosion


FireBallRemote.OnServerEvent:Connect(function(plr,mousepos,mousedir)
	local char = plr.Character or plr.CharacterAdded:Wait()
	local hrp = char:FindFirstChild("HumanoidRootPart")
	local NewFireBall = FireBall:Clone()
	local HitBox = script.ExplosionHitbox:Clone()
	NewFireBall.Parent = workspace
	NewFireBall.Position = hrp.Position
	local BodyVelocity = Instance.new("BodyVelocity")
	BodyVelocity.Parent = NewFireBall
	BodyVelocity.MaxForce = Vector3.new(50000,50000,50000)
	BodyVelocity.Velocity = mousedir*100

	NewFireBall.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid") ~= nil then
			if hit.Parent.Name ~= plr.Name then
				ExplosionSound:Play()
				local NewExplosionSound = ExplosionSound:Clone()
				local NewExplosionVFX = ExplosionVFX:Clone()
				NewExplosionVFX.Parent = workspace
				NewExplosionVFX.CFrame = NewFireBall.CFrame
				NewExplosionSound.Parent = NewFireBall
				HitBox.Parent = workspace
				HitBox.CFrame = NewFireBall.CFrame
				NewExplosionSound:Play()
				NewFireBall:Destroy()

				task.wait()
				local Info = TweenInfo.new(
					.5,
					Enum.EasingStyle.Quad,
					Enum.EasingDirection.In,
					0,
					false,	
					0
				)

				local goals = 
					{
						Transparency = 1;
					}

				local mpmtween = TweenService:Create(NewExplosionVFX, Info, goals)
				mpmtween:Play()
				HitBox.Touched:Connect(function(hit)
					if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= nil then
						if hit.Parent.Name ~= plr.Name then
							hit.Parent:FindFirstChild("Humanoid"):TakeDamage(8)
							HitBox:Destroy()
						end
					end
				end)
				task.wait(.5)
				NewExplosionVFX:Destroy()
				HitBox:Destroy()
			end
		end
	end)
	task.wait(2)
	NewFireBall:Destroy()
end)

I also get this error sometimes:

For these part of the code, you don’t need to add these as no matter what it wont give errors

Assuming this block is where the error is:

Change it to WaitForChild()

local char = plr.Character or plr.CharacterAdded:Wait()
	local hrp = char:WaitForChild("HumanoidRootPart")
	local NewFireBall = FireBall:Clone()
	local HitBox = script.ExplosionHitbox:Clone()
	NewFireBall.Parent = workspace
	NewFireBall.Position = hrp.Position
	local BodyVelocity = Instance.new("BodyVelocity")
	BodyVelocity.Parent = NewFireBall
	BodyVelocity.MaxForce = Vector3.new(50000,50000,50000)
	BodyVelocity.Velocity = mousedir*100

If not the case, it may be due to your and inside the if statement.

Plus, Cant you just Cast a Ray to deal damage if the fireball is that fast?

I’m kinda bad at rays but i will try. Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.