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

How can I create a once optainable leaderstat point?

Asked by
Drakyd 1
4 years ago

Hello guys! I would like to make a leaderstat which counts how many levels have you completed.

If you complate a stage twice it won't add another score

if you complete the 1st and 3rd level you'll get 2 score in all

0
Make a BoolValue that represents whether a player has completed a specific stage, when they do, set it to true, then if they complete the stage again, check to see if they already completed that stage (via the bool value) before awarding them theking48989987 2147 — 4y
0
Ughh.. could you please write step by step? I am VERY a beginner Drakyd 1 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Here's how you create folders and values to keep track of things like stats and points in a player, including whether or not they completed a level:

In ServerScriptService make a new script. This will be where you have the BoolValue created.

game.Players.PlayerAdded:Connect(function(player)

local LevelTracker = Instance.new("Folder")
LevelTracker.Parent = player
LevelTracker.Name = "LevelTracker"

    local Level1 = Instance.new("BoolValue")
    Level1.Parent = LevelTracker
    Level1.Name = "Level1"
    Level1.Value = false


end)

You'll need to make a folder called leaderstats and a value for your total points too. Hopefully the above should help you do that.

Then in the "goal" insert another script. When the goal is touched, it should do three things: check that you haven't completed Level 1 before, if so, mark that you have now completed it, and then give you a point. Should look something like this:

script.Parent.Touched:Connect(function(player)
    if game.Players[player.Parent.Name].LevelTracker.Level1.Value == false then
        game.Players[player.Parent.Name].LevelTracker.Level1.Value = true
        --Substitute points for whatever you name it
        game.Players[player.Parent.Name].leaderstats.Points.Value = game.Players[player.Parent.Name].leaderstats.Points.Value + 1
    elseif game.Players[player.Parent.Name].LevelTracker.Level1.Value == true then
    print("you already completed this level")
end
end)


Hopefully that helps you out. Good luck!

Ad

Answer this question