Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Leaderstat Giver/Teleport On Touch, not working?

Asked by 3 years ago

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.

0
Why dont do it when a player dies? jakeovi -1 — 3y
0
I'm making an obby/parkour game and don't want the player to fall for a while and reset. HonestlyDex 0 — 3y
0
you can just make a that barrier thing kill on touch, and when the player dies, it adds the deaths value jakeovi -1 — 3y

Answer this question