Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why wont the fireball do any damage?

I have a tool that when activated will shoot a fireball and when that collides with a player it will deal damage to the targets humanoid. This is a simulator game (like superpower training simulator) so the damage of the fireball will be different depending on the players fist strength but for some reason it doesn't deal any damage. Here's the script:

local Tool = script.Parent
local Cooldown = false
local CDTime = 1.5



Tool.RemoteEvent.OnServerEvent:Connect(function(Player,Mouse)
	if Cooldown then return end 

	spawn(function()
		Cooldown = true 
		wait(CDTime)
		Cooldown = false 
	end)

	local sphere = game.ReplicatedStorage.Abilities.EnergySphere.Sphere1:Clone()
	sphere.Parent = game.Workspace
	local Position = Player.Character.Head.Position + CFrame.new(Player.Character.Head.Position).lookVector * 1 
	sphere.CFrame = CFrame.new(Position)
	sphere.Orientation = Player.Character.Head.Orientation
	sphere.CanCollide = false
	sphere.Anchored = false
	sphere:SetNetworkOwner(Player)
	local BodyVelocity = Instance.new("BodyVelocity",sphere)
	BodyVelocity.Velocity = Mouse.lookVector * 50
	BodyVelocity.MaxForce = Vector3.new(1e8,1e8,1e8)
	game.Debris:AddItem(sphere,1.8)


	sphere.Touched:Connect(function(hit)
		if hit.Parent == Player.Character then return end
		if hit and hit.Parent:FindFirstChild("Humanoid") then 
			local EnemyHum = hit.Parent:FindFirstChild("Humanoid")
			Player.Data.Strength:GetPropertyChangedSignal("Value"):Connect(function()
				EnemyHum:TakeDamage(Player.Data.Strength.Value)
			end)
			Tool.Explosion:Play()
			sphere:Destroy()

		end
	end)
end)	


1 answer

✓ Accepted answer

There's lots of things about this code that is incorrect, but I'll go over the main topic

-- replace this for lines 32 - 35

if hit.Parent:FindFirstChild("Humanoid") then 
hit.Parent.Humanoid:TakeDamage(Player.Data.Strength.Value) 
end

If this doesnt work, reply, I'll rewrite a completely new script.

1 comment

0

Ok thanks, and I know there's probably alot of things wrong with it but until i tried this, everything worked well and fine so yeah.

This discussion is preserved as it was. New answers, comments, and votes are closed.