Hey I’m new to scripting and I’ve encountered a problem with a script that’s used for burning players. Whenever someone touches the brick its supposed to check who touched the brick then affect that player and allow other players to also receive damage if they touch it. The problem with this is that every time someone does touch the brick then they’ll receive damage but no one else is able to until the script finishes for the person who touched it. I’m using a server sided script for this. Help would be appreciated!
local dmgbrick = script.Parent
local debounce = false
dmgbrick.Touched:Connect(function(body)
local player = game.Players:GetPlayerFromCharacter(body.Parent)
local p = body.Parent.Torso.PlayerValue.Value
if player.Name == p then
local humanoid = body.Parent:FindFirstChild("Humanoid")
if humanoid then
if debounce then return end
debounce = true
local bodyid = body.Parent.Torso.fire_area
local fire = Instance.new("Fire")
fire.Name = "burn"
fire.Size = 6
fire.Parent = bodyid
humanoid.Health = humanoid.Health - 25
for i = 1, 5 do
if humanoid.Health <= 5 then
humanoid.Health = -2
end
humanoid.Health = humanoid.Health - 5
fire.Size = fire.Size - 1
task.wait(1)
end
fire:Destroy()
debounce = false
end
end
end)