Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is this not working?

local O = script.Parent.Owner.Value
local P = game.Players:FindFirstChild(O)
while true do
	if P.leaderstats then
		P.leaderstats.Cash.Value = script.Parent.Owner.Money.Value
	end
	wait()
end

Error code in output: Workspace.Tycoon.CashHandlerScript:6: attempt to index local 'P' (a nil value)

2 comments

0

Your code is perfectly fine, just ther was no player matching the Owner's value.

0

No, I found the answer, It's because i put the ".Value' in line 1 what i needed to do what put it in line 2 like :FindFirstChild(O.Value)

1 answer

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:

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

1 comment

0

Or use :WaitForChild().

This discussion is preserved as it was. New answers, comments, and votes are closed.