You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
Have my leaderstats show in game.
- What is the issue? Include screenshots / videos if possible!
The leaderstats model will not create
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Switching between making a model and a folder.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
My code:
-- CREATE AND STORE STATS IN ROBLOX SERVERS
--=========================================--
-- Create the spot to keep data
local datastore = game:GetService("DataStoreService"):GetDataStore("GCGRs-Speed-Sim-Data")
-- Function for when player joins
function onPlayerEntered(player)
-- Create player stat keys
local initKey = "user_" .. player.userId .. "_init"
local stepsKey = "user_" .. player.userId .. "_steps"
local pointsKey = "user_" .. player.userId .. "_points"
local speedKey = "user_" .. player.userId .. "_speed"
local trailKey = "user_" .. player.userId .. "_trail"
-- Create defalts for new players
if(datastore:GetAsync(initKey) == nil) then
datastore:SetAsync(initKey, true)
datastore:SetAsync(stepsKey, 0)
datastore:SetAsync(pointsKey, 0)
datastore:SetAsync(speedKey, 1)
datastore:SetAsync(trailKey, "DefaultTrail")
end
if(datastore:GetAsync(trailKey) == nil)then
datastore:SetAsync(trailKey, "DefaultTrail")
end
-- Load in last saved data
local init = datastore:GetAsync(initKey)
local steps = datastore:GetAsync(stepsKey)
local points = datastore:GetAsync(pointsKey)
local speed = datastore:GetAsync(speedKey)
local trail = datastore:GetAsync(trailKey)
--=========================================--
-- Create Leaderboards
--=========================================--
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local stepsBoard = Instance.new("IntValue")
stepsBoard.Name = "Steps"
stepsBoard.Value = steps
stepsBoard.Parent = leaderstats
end
--=========================================--
-- Runs onPlayerEntered
game.Players.PlayerAdded:Connect(onPlayerEntered)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.