My leaderstats script keeps having the same problem ServerScriptService:20 plr(a nil value) i have changed it around to do LocalPlayer but its the same error here is the script: ```lua

local ds = game:GetService("DataStoreService"):GetDataStore("DataStore1") local plr = game.Players.LocalPlayer game.Players.PlayerAdded:Connect(function(PlayerEntered) if PlayerEntered then if PlayerEntered and not plr then game.Players:GetPlayerFromCharacter(plr)

		local leaderstats = Instance.new("Folder")
		leaderstats.Name = "leaderstats"
		leaderstats.Parent = plr
		
		local TeaDrank = Instance.new("NumberValue")
		TeaDrank.Name = "Tea Drank"
		TeaDrank.Parent = leaderstats
		TeaDrank.Value = 0
		
		local cash = Instance.new("IntValue")
		cash.Name = "Cash"
		cash.Parent = leaderstats
		cash.Value = 50 + game.Players.LocalPlayer.leaderstats.Cash.Value / 0
					
	end
end

end)

Do you think it is wrong or right? P.S this is for a youtube tutorial so I have to post the vid in 1 day. So pls help.

2 comments

0

I'm pretty sure only server-script based scripts work in the ServerScriptService, this may be your issue.

0

You have to specifically tell the script which player, LocalPlayer is only used for Client side.