So basically i'm making a script that when you fall off the map and touch it, it gives you 1 "Deaths" leaderstat. But, it isn't working. Here is my code:
local part = script.Parent local canGet = true local function onTouch(otherPart) local humanoid = otherPart.Parent:FindFirstChild('Humanoid') if humanoid then local player = game.Players:FindFirstChild(otherPart.Parent.Name) if player and canGet then canGet = false player.leaderstats.Deaths.Value = player.leaderstats.Deaths.Value + 1 function onTouch(part) if part.Parent.Humanoid ~=nil then part.Parent:MoveTo(script.Parent.Parent.Parent.Parent.GoBack1.Position) script.Parent.Parent.Parent.Parent.GoBack1.Script.Disabled = true wait(2) script.Parent.Parent.Parent.Parent.GoBack1.Script.Disabled = false end end script.Parent.Touched:connect(onTouch) wait(60) canGet = true end end end part.Touched:Connect(onTouch)
Thank You.