1 | local O = script.Parent.Owner.Value |
2 | local P = game.Players:FindFirstChild(O) |
3 | while true do |
4 | if P.leaderstats then |
5 | P.leaderstats.Cash.Value = script.Parent.Owner.Money.Value |
6 | end |
7 | wait() |
8 | end |
Error code in output: Workspace.Tycoon.CashHandlerScript:6: attempt to index local 'P' (a nil value)
As Goulstem already stated, there is nothing wrong with the script at all. Make sure your other scripts are correct, and that the value is there in the first place.
I'd suggest adding in this before defining the variable:
1 | repeat wait() until script.Parent.Owner.Value |
That'd help make sure that there is a value in there before the script tries going through the rest of your code.
Anyways, hope I helped a bit, and if you have any questions or problems, please leave a comment below :P