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.
01 | game.Players.PlayerAdded:Connect( function (player) |
03 | local LevelTracker = Instance.new( "Folder" ) |
04 | LevelTracker.Parent = player |
05 | LevelTracker.Name = "LevelTracker" |
07 | local Level 1 = Instance.new( "BoolValue" ) |
08 | Level 1. Parent = LevelTracker |
09 | Level 1. Name = "Level1" |
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:
1 | script.Parent.Touched:Connect( function (player) |
2 | if game.Players [ player.Parent.Name ] .LevelTracker.Level 1. Value = = false then |
3 | game.Players [ player.Parent.Name ] .LevelTracker.Level 1. Value = true |
5 | game.Players [ player.Parent.Name ] .leaderstats.Points.Value = game.Players [ player.Parent.Name ] .leaderstats.Points.Value + 1 |
6 | elseif game.Players [ player.Parent.Name ] .LevelTracker.Level 1. Value = = true then |
7 | print ( "you already completed this level" ) |
Hopefully that helps you out. Good luck!