Problem with my projectile

local projectile = script.Parent
local players = game:GetService("Players")
local damage = 10
local rs = game:GetService("ReplicatedStorage")
local fire = rs:WaitForChild("FireMagic")
local hitfx = fire:WaitForChild("HitFX")

projectile.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local character = hit.Parent
		local player = players:GetPlayerFromCharacter(character)
		local humanoid = character:WaitForChild("Humanoid")
		humanoid:TakeDamage(damage)
		task.wait(1)
		projectile:Destroy()
	elseif not hit.Parent:FindFirstChild("Humanoid") then
		local XD = hitfx:Clone()
		XD.Parent = workspace
		XD.CFrame = projectile.CFrame
		task.wait(3)
		projectile:Destroy()
	end
end)

I’ve moved HitFX to the ReplicatedStorage folder and made some other minor changes.