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

How do I define a NumberValue in a leaderstats folder with a normal script(not a local script)?

Asked by 5 years ago

I'm making a simulator game and I need to define a Number Value called Strength in a folder called leaderstats in a normal script and not a local script. How do I define a certain players leaderstats folder and Strength Number Value?

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

It's a simple as:

01-------Server Script
02 
03local Players = game:GetService("Players")
04 
05 
06Players.PlayerAdded:Connect(function(Player) ------Connect A function when A player Joins The Game
07    if Player then
08        local leaderstats = Instance.new("Folder", Player) ----Create a new Folder
09        leaderstats.Name = "leaderstats"---- Give it a Name
10        local NumberValue = Instance.new("NumberValue", leaderstats) -----Create a Value
11        NumberValue.Name = "NumberValue" --- Give it a Name
12    end
13end)
Ad

Answer this question