Hello Roblox developers, so the issue I’m having is when a player falls into the lava, a death count gets added to the leaderboard, but it gets triggered to many times. So what I did to resolve this issue is to add debouncing to my code… But now I’m having another issue when that same player touches that same part of lava, the new death count does not get uploaded to the leaderboard. if any knows how to fix this issue please let me know thanks! you can view my code below
local lava = script.Parent
local function killplayer(otherpart)
local partparent = otherpart.Parent
local humanoid = partparent:FindFirstChild("Humanoid")
if humanoid then
humanoid.Health = 0
end
end
lava.Touched:Connect(killplayer)
local isTouched = false ----where the leaderboard code starts
local function touched(hit)
if isTouched then
return
end
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player then
local Deaths = Player.leaderstats.Deaths
Deaths.Value = Deaths.Value + 1
isTouched = true
end
end
lava.Touched:Connect(touched)