I'm trying to make my game take 250 from players when I activate a Fireserver.
game.ReplicatedStorage.Take250.OnServerEvent:Connect(function(player)
game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value - 250
end)
However I get this error when i activate the Fireserver
ServerScriptService.Take cash:2: attempt to index nil with 'leaderstats'
What does this mean and how can I fix it.
Also this is just a part of my leaderboard script in case it helps
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
-- Display an 'IntValue' on leaderboard
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Parent = leaderstats

2 comments
Everything involving in-game currency should be server-sided, so why are you firing an event from the client?
i'm making a car purchase gui and everything works but taking the cash