Simple Stats System! | FancyTaik123's Scripting Tutorial

Hey there! I’m FancyTaik123! This is my very first tutorial on the devforums so here we go! Today, we will be learning how to make a simple stats system using one script. Before I start, here are some things you need to do. First, open up Roblox Studio (or download it if you don’t have it). Once Roblox Studio is opened, select a place you would like to work on (if you don’t have one it’s ok, simply click on new

and open up a baseplate . Once you have done all that, you are set

Here we go!

Select on ServerScriptService and insert a script! image
Once you have inserted a script, open up the script and remove print("Hello World") at the very top of the script! Once removed, start off by defining players by doing

local players = game:GetService("Players")

After that, you would need to detect when a player joins the game. You do that by doing

players.PlayerAdded:Connect(function(player)

end)

This would detect when the player joins the game! Next up, you would need to create an instance for when the player joins the game. You can do this by doing this inside of the function

local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats" -- make sure the l is lowercase
leaderstats.Parent = player

Your script should look something like this by now.

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
     local leaderstats = Instance.new("Folder")
     leaderstats.Name = "leaderstats" -- make sure the l is lowercase
     leaderstats.Parent = player
end)

The next step is really simple. All you have to do now is create the stats! For this tutorial I will be making the stats coins but you can do as many as you’d like! This would go after making the leaderstats instance

local coins = Instance.new("NumberValue")
coins.Name = "Coins"
coins.Value = 0 -- the value the player starts off with!
coins.Parent = leaderstats

And here is the final product!

And that’s it! Obviously this does not save the data but I will be making a tutorial soon for data saving! Bye :wave:

PS If you ever need help, you can always contact me on twitter (www.twitter.com/fancytaik123) or on discord (FancyTaik123#3698)!

Final Script

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local coins = Instance.new("NumberValue")
	coins.Name = "Coins"
	coins.Parent = leaderstats
end)
4 Likes

This topic was automatically closed after 1 minute. New replies are no longer allowed.