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

How to I increase the levels value on the leader board if the player completes a level in an obby?

Asked by
Soban06 410 Moderation Voter
4 years ago

So I am trying to make an obby and I have stages. In the leaderboard, I have 2 values: Coins and levels. So what I am trying to explain is that when the player completes the level and stands on the checkpoint, the levels value should increase as the player completes the level. How can I achieve this?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

well, just add a script in the brick that will be touched to level up, and add an integer value(Int value) in the brick and give it a value of the level; then do the following

script.Parent.Touched:connect(function(touching)
    local parent = touching.Parent
    locla humanoid = Parent:FindfirstChild("Humanoid")
    local player;

    if humanoid then
        player = game.Players:GetPlayerFromCharacter(parent)
        if player then
            local leaderstats = player.leaderstats
            local level = leaderstats.Level -- rename level to whatever the level value is 
named       
        level.Value = script.Parent.LevelValue -- change this to the name of the number value in the brick
        end
    end
end)
0
You don't need to check for a Humanoid if you're using GetPlayerFromCharacter(). If GetPlayerFromCharacter() returns a player, it means that the character automatically has a Humanoid. DeceptiveCaster 3761 — 4y
0
Also: "just add a remoteevent in replicatedstorage", you don't actually need a RemoteEvent. The server can access the children of a player. DeceptiveCaster 3761 — 4y
0
good catch, i was meaning to answer a question with a complex system that automates all the leveling, but after thinking about it, I decided to go basic, and forgot to remove that. Thanks User#23252 26 — 4y
0
I am also at school, and I was running out of time when i was writting this, so i guess that contributes to the errors User#23252 26 — 4y
Ad

Answer this question