I have apart of a script which just isnt working. Im trying to deal damage witth this explosion in a fireball. Though its not working. no errors in the output. Boom is already defined as an instance.new(explosion) earlier in the script. this is just the part that isnt working. No errors in the output. this is a local script inside a tool.
boom.Hit:connect(function(hit)
if hit ~= nil and hit.Parent:FindFirstChild('Humanoid') and hit.Parent ~= player.Character and hit.parent ~= nil then
local humanoid1 = hit.Parent:FindFirstChild('Humanoid')
humanoid1:TakeDamage(50)
end
end)
This will locally damage the humanoid. The explosion being made on the server will not allow a local script to damage people globally. If this isn’t the issue try using debugging methods to see if the script gets passed the if statements.
But how would that stop the explosion itself from dealing damage, (when a humanoid is next to it, not colliding with the fireball because the fireball does damage on its own)
I’m saying that the problem is that explosion.hit is returning more than one part of a character. The problem you are facing is that it might hit the character 20 times dealing 20 times more damage.
Thats not the issue since it only deals damage twice. The function only deals damage when the fireball hits someone, I want it to deal damage when someone is hit by the explosion
I don’t understand why the script you wrote (assuming you fixed it being local) wouldn’t work in this situation. It should deal damage to humanoids that are hit by the explosion, right?
Well the fireball automatically explodes on impact with a player. In this part of the script, the part were talking about is supposed to deal damage to whoever is hit by the explosion that is caused when it hits a part and a player. Though the function is firing when it hits the player and not a part.
Hopefully that makes sense
boom.Hit:connect(function(hit)
if hit ~= nil and hit.Parent ~= player.Character and hit.Parent ~= nil and hit.Parent:FindFirstChild('Humanoid',true) then
local humanoid1 = hit.Parent:FindFirstChild('Humanoid')
humanoid1:TakeDamage(50)
end
end)
boom.Touched:Connect(function(hit)
local human = hit.Parent:FindFirstChildOfClass('Humanoid')
if human ~= nil and hit:IsDescendantOf(player.Character) == false then
human:TakeDamage(50)
end
end)