Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I create a once optainable leaderstat point?

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

2 comments

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

0

Ughh.. could you please write step by step? I am VERY a beginner

1 answer

✓ Accepted answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.