Why does this line of code have an error
Do you have the player variable in the create leader stats function?
What do you mean by that?‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎
Can you show the create leader stats function?
That is what the image is on the top
You’re calling a function there what code runs when you call it?
Local function CreateLeaderStats(player)
end
Got that
Can you put your mouse in the error line and read what it wrote ?
So where do you get the player from?
Uhhhh I dont know. Should I show you my full code
Does the code run? Or does it error at that spot?
When you test does it work? ?,
Errors at the spot I dont know why
Then yeah you should just share your whole code so we can see where you’re getting everything.
Sure
local Players = game:GetService(“Players”)
local ServerScriptService = game:GetService(“ServerScriptService”)
local Template = require(ServerScriptService.PlayerData.Template)
local Manager = require(ServerScriptService.PlayerData.Manager)
local ProfileService = require(ServerScriptService.Libs.ProfileService)
local ProfileStore = ProfileService.GetProfileStore(“2”, Template) – (1 = Test) (2 = Production)
local KICK_MESSAGE = “Could not find data Please rejoin If issue persists, contact us via group wall”
local function CreateLeaderStats(player: Players)
local profile = Manager.Profiles[player]
if not profile then return end
local leaderstats = Instance.new("Folder", Players)
leaderstats.Name = "leadestats"
local coins = Instance.new("NumberValue", leaderstats)
coins.Name = "Clicks"
coins.Value = profile.Data.Clicks
local Gems = Instance.new("NumberValue", leaderstats)
Gems.Name = "Gems"
Gems.Value = profile.Data.Gems
end
local function LoadProfile(player: Player)
local profile = ProfileStore:LoadProfileAsync(“Player_”…player.UserId)
if not profile then
Players:Kick(KICK_MESSAGE)
return
end
profile:AddUserId(player.UserId)
profile:Reconcile()
profile:ListenToRelease(function()
Manager.Profiles[player] = nil
Players:Kick(KICK_MESSAGE)
end)
if player:IsDescendantOf(Players) == true then
Manager.Profiles[player] = profile
CreateLeaderStats(player)
else
profile:Release()
end
end
for _, Player in Players:GetPlayers() do
task.spawn(LoadProfile, Players)
end
Players.PlayerAdded:Connect(LoadProfile)
Players.PlayerRemoving:Connect(function(Players)
local profile = Manager.Profiles[Players]
if profile then
profile:Release()
end
end)
There is 2 other scripts do you want to know those to?
I dont use ProfileService but it could be because you’re doing player: Players
, which I believe would make the script think it is the game service “Players”. Try changing it to player: Player
?
I will try it!
Edit ; nope it dosnt work