Leaderstats won't showing up

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want someone to help with this bug.
  2. What is the issue? Include screenshots/videos if possible!
    Issue: Leaderstats won’t show up, even I play on studio and in-game.
    https://gyazo.com/e6ebe226576ee09b84cb7efb2a97582a
    https://gyazo.com/9880c1a9007243ea6815a13e71c344a0
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Script:
game.Players.PlayerAdded:Connect(function(plr)
local idkey = plr.UserId – i made datastore on below
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “Leaderstats”
leaderstats.Parent = plr

local checkpoints = Instance.new("IntValue")
checkpoints.Name = "Zone"
checkpoints.Value = 1
checkpoints.Parent = leaderstats

Full script:
local datastore = game:GetService(“DataStoreService”)
local SData = datastore:GetDataStore(“SDataStore”)
– player added
game.Players.PlayerAdded:Connect(function(plr)
local idkey = plr.UserId
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “Leaderstats”
leaderstats.Parent = plr

local checkpoints = Instance.new("IntValue")
checkpoints.Name = "Zone"
checkpoints.Value = 1
checkpoints.Parent = leaderstats

local data
local success, err = pcall(function()
	data = SData:GetAsync(idkey)
end)
    if data == nil then
	plr.Leaderstats.Zone.Value = 1
else
    plr.Leaderstats.Zone.Value = data
end

end)

– player leaving
game.Players.PlayerRemoving:Connect(function(plr)
local data
local idkey = plr.UserId
local success, err = pcall(function()
SData:GetAsync(idkey)
if data == nil then
SData:SetAsync(idkey, plr.Leaderstats.Zone.Value)
else
SData:UpdateAsync(idkey, function(oldvalue)
local newValue = oldvalue or 1
return newValue
end)
end
end)
if success then
print(“Success for”… plr.Name…“with”…plr.Leaderstats.Zone.Value)
else
print(“Failed for”… plr.Name)
print(err)
end
end)

I feel like this is a bug. Can someone help me how to fix this?


1 Like

Make there “leaderstats”

I hope it helps :slight_smile:

2 Likes

I will try. Thanks for respond.

1 Like

Bruh, it work. I thought capitilize letters still work on leaderstats name.

1 Like