i have a leaderboard script set up in workspace and this is it..

--Variables
local leveldata = game:GetService("DataStoreService"):GetDataStore("level")
local EXPdata = game:GetService("DataStoreService"):GetDataStore("EXP")
local xpLeveldata = game:GetService("DataStoreService"):GetDataStore("xpLevel")
local Golddata = game:GetService("DataStoreService"):GetDataStore("Gold")
local HttpService = game:GetService("HttpService")


--Data Storage Save
function savedata(dataname, playerid, value)
	game:GetService("DataStoreService"):GetDataStore(dataname):SetAsync(playerid, value)
end

--Leaderboard Variables
game.Players.PlayerAdded:connect(function(player)
	playerKey = "user_"..player.userId	-- user key
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	--Gold
	local gold = Instance.new("IntValue")
	gold.Name = "Gold"
	gold.Value = Golddata:GetAsync(playerKey) or 0
	gold.Parent = leaderstats

	
	--Level
	local level = Instance.new("IntValue")
	level.Value = leveldata:GetAsync(playerKey) or 1
	level.Name = "Level"
	level.Parent = leaderstats

	
	--XP
	local EXP = Instance.new("IntValue")
	EXP.Value = EXPdata:GetAsync(playerKey) or 0
	EXP.Parent = player
	EXP.Name = "Exp"
	
	--XP Needed
	local xpLevel = Instance.new("IntValue")
	xpLevel.Value = xpLeveldata:GetAsync(playerKey) or 500
	xpLevel.Name = 'ExpNeeded'
	xpLevel.Parent = player
	


game.Players.PlayerRemoving:Connect(function(player) -- save player stats
	savedata('level',playerKey,player.leaderstats.Level.Value)
	savedata('EXP',playerKey,player.Exp.Value)
	savedata('xpLevel',playerKey,player.ExpNeeded.Value)
	savedata('Gold',playerKey,player.leaderstats.Gold.Value)
end)

sorry, very hefty amount of code but my datastore is combined in there. i just want to know why i am the only one who can see the leaderboard.

1 comment

0

i really dont everyone should be able to