#How to get more scripts in leaderboard?
13 messages · Page 1 of 1 (latest)
game.Players.PlayerAdded:Connect(function(plr)
local folder = Instance.new("Folder")
folder.Parent = plr
folder.Name = "leaderstats"
local money = Instance.new("NumberValue")
money.Parent = folder
money.Name = "Money"
local Time= Instance.new("NumberValue")
Time.Parent = folder
Time.Name = "Time"
end)
I dont know. I took the scripts from youtube tutorials they are not made by me. At first there was cash in leaderstats and it was working. After i added the time script my shop is not working. Cash gui is also not working and i dont see the cash in the leaderstats. I just want to somehow add the cash in the leaderstats with the time script also. Im like super new in roblox scripting 😄
** You are now Level 1! **
just use one script like the one ive sent
You mean like get everything in one script? 😄
that script creates two Values (Money and Time)
and it shows it on your screen
Like the time im alive?
And then it resets? 😄
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("DataStore")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local aliveTime = Instance.new("IntValue")
aliveTime.Name = "Time Alive"
aliveTime.Parent = leaderstats
local bestTime = Instance.new("IntValue")
bestTime.Name = "Best Time"
bestTime.Parent = leaderstats
local data
local success, message = pcall(function()
data = DataStore:GetAsync(plr.UserId .. "-Data")
end)
if success then
if data then
bestTime.Value = data
end
else
warn(message)
plr:Kick("Error while retrieving your data.")
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local data = plr.leaderstats["Best Time"].Value
local success, message = pcall(function()
DataStore:SetAsync(plr.UserId .. "-Data", data)
end)
if not success then
warn(message)
end
end)
This is the time script
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new("NumberValue")
cash.Name = "Cash"
cash.Value = 0
cash.Parent = leaderstats
And this is the Cash script