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

How do I stop this leaderstat from increasing?

Asked by
yayachik1 -11
2 years ago

I have a script in serverscriptservice that increases your jump height every 1 second and I was working on adding a rebirths stat that once you reach a certain jump height you can rebirth and it will reset your jumpheight and increase your rebirths value by + 1, this works, however when you click to rebirth the jumpheight value spazzes out and the number doesn't stay consistent or reset to 0. any help is appreciated.

game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local jumpVal = Instance.new("IntValue")
    jumpVal.Name = "JumpHeightPower"
    jumpVal.Parent = leaderstats

    local rebirths = Instance.new("IntValue")
    rebirths.Name = "Rebirths"
    rebirths.Parent = leaderstats


    player.CharacterAdded:Connect(function(char)

        local totalJumpHeight 
        local char = char:WaitForChild("Humanoid")

        if totalJumpHeight then
            print(", " .. totalJumpHeight)
            char.JumpHeight = totalJumpHeight
        end

        increaseStats(char, jumpVal)

        char.Died:Connect(function()
            totalJumpHeight = char.JumpHeight
        end)

    end)

end)


function increaseStats(char, jumpVal)
    spawn(function()
        while wait(1) do
            char.JumpHeight += 1

            jumpVal.Value = char.JumpHeight
        end
    end)
end


game.ReplicatedStorage.Rebirth.OnServerInvoke = function(player)
    if player.leaderstats.JumpHeightPower.Value > 10 then
        player.leaderstats.Rebirths.Value += 1
        player.leaderstats.JumpHeightPower.Value = 0
    end
end


0
You are making the jump height to do go 0 in line 50 VAnkata20 135 — 2y

Answer this question