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

Why doesnt the value show in the leaderboard?

These are the two scripts both in seperate scripts

game.Players.PlayerAdded:connect(function(player)

local leaderstats = Instance.new("IntValue") leaderstats.Name = "leaderstats" leaderstats.Value = 0

local rank = Instance.new("StringValue") rank.Name = "Rank" rank.Value = player:GetRoleInGroup(4117755) -- put group id in parentheses

leaderstats.Parent = player rank.Parent = leaderstats

end)

local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("CashSaveSystem")

game.Players.PlayerAdded:connect(function(player) local leader = Instance.new("Folder",player) leader.Name = "leaderstats" local Cash = Instance.new("IntValue",leader) Cash.Name = "Cash" Cash.Value = ds:GetAsync(player.UserId) or 0 ds:SetAsync(player.UserId, Cash.Value) Cash.Changed:connect(function() ds:SetAsync(player.UserId, Cash.Value) end) end)

game.Players.PlayerRemoving:connect(function(player) ds:SetAsync(player.UserId, player.leaderstats.Cash.Value) end)

1 comment

0

Please put the scripts in code blocks so we can properly read it.

1 answer

game.Players.PlayerAdded:connect(function(player)
	local leaderstats = Instance.new("IntValue") 
	leaderstats.Name = "leaderstats" 
	local rank = Instance.new("StringValue") 
	rank.Name = "Rank" 
	rank.Value = player:GetRoleInGroup(4117755) -- put group id in parentheses
	rank.Parent = leaderstats

	leaderstats.Parent = player
	rank.Parent = leaderstats

end)
local DataStore = game:GetService("DataStoreService") 
local ds = DataStore:GetDataStore("CashSaveSystem")

game.Players.PlayerAdded:connect(function(player) 
	local leader = Instance.new("Folder",player) 
	leader.Name = "leaderstats" 
	local Cash = Instance.new("IntValue",leader) 
	Cash.Name = "Cash" 
	Cash.Value = ds:GetAsync(player.UserId) or 0 
		ds:SetAsync(player.UserId, Cash.Value) 
	Cash.Changed:connect(function() 
		ds:SetAsync(player.UserId, Cash.Value) 
	end) 
end)

try this?

1 comment

0

I did it didnt work

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