#ServerScript in ServerStorage can't find player's leaderstats
36 messages · Page 1 of 1 (latest)
** You are now Level 1! **
nope
Thats why
i just have a serverscript
Let code one for you
game.Players.PlayerAdded:Connect(function(player)
local leaderstats= Instance.new("Folder")
leaderstats.Name= ("leaderstats")
leaderstats.Parent= player
--now currency
local level= Instance.new("IntValue")
level.Name= ("Level")
level.Parent = leaderstats
level.Value = 500
end)
Ye
this is what i've been using
put that in the script
Workspace.cookiemaster2448.CharacterBar.Script:16: attempt to index nil with 'leaderstats'
:/
game.Players.PlayerAdded:Connect(function(player)
local leaderstats= Instance.new("Folder")
leaderstats.Name= ("leaderstats")
leaderstats.Parent= player
local level= Instance.new("IntValue")
level.Name= ("Level")
level.Parent = leaderstats
level.Value = 500
end)
local player = game.Players.LocalPlayer
local playerLevel = player.leaderstats.level.Value
script.Parent.parent.levelText.Text = playerLevel
Have you learnt the basics of scripting?
yea
Use game. where ever it is
this is a script in a frame in serverstorage, it won't create the folder from this script
so i have the other code in serverscriptservice
For example if I want to make a variable for a part in workspace i will do: local part = game.Workspace:FindFirstChild("Part")
OH
lol
wait lemme
nah still didn't work
local playerLevel = game.Players.LocalPlayer.leaderstats.level.Value
script.Parent.parent.levelText.Text = playerLevel
that didn't work either, and moving the script to serverscript service yielded ServerScriptService.Script:1: attempt to index nil with 'leaderstats'
local playerLevel = game.Players.LocalPlayer.leaderstats.level.Value
game.ServerStorage.CharacterBar.levelText.Text = playerLevel
print(playerLevel)
** You are now Level 2! **
it seems the script can't find the leaderstats
make a player value