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

Why am i getting damaged only once when i walk into my damagearea?

I made a Volcano with a damagearea but im only getting damged once (when i enter the area)

Script inside the damagearea:

script.Parent.Touched:Connect(function(hit)

	if hit.Parent:FindFirstChild("Humanoid") and not hit.Parent:FindFirstChild("LavaHit") then
		local I = Instance.new("IntValue",hit.Parent)
		I.Name = "LavaHit"
		game.Debris:AddItem(I,5)
		hit.Parent.Humanoid:TakeDamage(10)
	end
end)

1 comment

1

I recommend using Region3 tbh.

2 answers

✓ Accepted answer

Touched events only fire once, and that's when the object is on the edge of the collision area. Use Region3s.

2 comments

0

ok but how

0

You can just use a simple script using the take damage thingy

I`m to lazy to rewrite the script, so I got one from the Dev Forum

local dmg = script.Parent.DamageValue.Value

script.Parent.Touched:Connect(function(part)
    local humanoid = part.Parent:FindFirstChild("Humanoid")
    if humanoid then
        humanoid:TakeDamage(dmg)
    end
end)

It is a pretty simple script, you just add an IntValue named DamageValue and assign the damage you want to be dealt when it is touched. If you want to make it damage you multiple times I have a model of an effective damage brick which takes a customizable amount of damage and after a customizable interval of time it will take the same amount of damage. Here https://web.roblox.com/catalog/5618332380/Damage-Brick

1 comment

0

Hope that helps!

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