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
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!