script.Parent.Main.MouseButton1Click:Connect(function() local player = game.Players.LocalPlayer player.leaderstats.Cashl.Value = player.leaderstats.Cashl.Value + 1 -- the error line. end)
literally three seconds later i found out i had "game.Players.LocalPlayer"
here is the fix lol:
-- Normal script: script.Parent.GiveCash.OnServerEvent:Connect(function() local player = script.Parent.Parent.Parent local Debounce = false if Debounce == false then Debounce = true player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1 wait() Debounce = false end end) -- Local script: script.Parent.MouseButton1Click:Connect(function() script.Parent.Parent.GiveCash:FireServer() end)
that was because "game.Players.LocalPlayer" is nil to the server.
https://devforum.roblox.com/t/attempt-to-index-nil-with-leaderstats/530935