My code is here, and I am using a script on line 20 is where the error is
local player = game.Players.LocalPlayer game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("IntValue",player) leaderstats.Name = "leaderstats" local Kills = Instance.new("IntValue",leaderstats) Kills.Name = "Kills" Kills.Value = 0 local Deaths = Instance.new("IntValue",leaderstats) Deaths.Name = "Deaths" Deaths.Value = 0 local Cash = Instance.new("IntValue",leaderstats) Cash.Name = "Cash" Cash.Value = 1000 end) game.ReplicatedStorage.Bought.BoughtACR.OnServerEvent:Connect(function() if player.leaderstats.Cash.Value >= 1000 then -- works until here print("something") player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 1000 end end)
You did not define player, the OnServerEvent has a player argument by default. Starting on line 19, define player like this:
game.ReplicatedStorage.Bought.BoughtACR.OnServerEvent:Connect(function(player) if player.leaderstats.Cash.Value >= 1000 then -- works until here print("something") player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 1000 end end)
This will fix your error.