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

[SOLVED] Please help me i got a RBXL script error, i tried to fix it and i wasted 1 hour how i fix?

PLR = game.Players:GetChildren(game.Workspace.GREEN.PLRNAME.Value)


> function onClicked()
	> if PLR.leaderstats.Money.Value >49 then
		game.Lighting.oldmachinegreensmall.Parent = game.Workspace
	end
	end



script.Parent.ClickDetector.MouseClick:connect(onClicked)

then it gives an error:

Workspace.Sign.Text.Script:10: attempt to index field 'leaderstats' (a nil value)

11 comments

0

i also have an leaderboard.

0

Change "GetChildren" to "findFirstChild" in the first line

0

ok ill try

0

No. Just learn Lua tbh.

0

Workspace.Sign.Text.Script:10: attempt to index global 'PLR' (a nil value) 21:55:35.167 - Stack Begin

0

OOOFFFF

0

You can't access Players through a ServerScript, try using a for i,v loop to gatheall the players into a table using the table value inside the parentheses of pairs game.Players:GetPlayers()

0

That is if it's a ServerScript, also instead of using a StringValue from workspace, just call it through ""

0

ill have to explain everything to fix this problem.

0

Just learning Lua is exactly what he's doing. Why not try to help the kid? Anyways, the problem is basically saying that the script couldn't find a player whose name was the same as game.Workspace.GREEN.PLRNAME.Value so what you need to do is make sure that that value contains a valid player name at the time that the variable PLR is defined

0

kid? I am an angry teenager

1 answer

For first, remove the >, and on click you can get player

And the :connect is deprecated, use :Connect

--Server Script(Script)

-- You dont need to use game.Workspace, you can use workspace

function onClicked(plr) -- On click get player
	if plr.leaderstats.Money.Value >= 50 then -- Changed > 49 to >= 50 / Detect money
		game.Lighting.oldmachinegreensmall.Parent = workspace -- Clone item and put on Workspace
		-- You can storage the item in ServerStorage. dont use Lighting for this.
	end
end

script.Parent.ClickDetector.MouseClick:Connect(onClicked) -- On click start function, with sending the player

Wiki pages:

Conditional Statements

Click Detector - MouseClick

Hope it helped :)

Errors? tell-me on comments.

10 comments

0

you are the best you made me cry xd

0

If solved your problems, accept answer or put [SOLVED] in title.

0

:connect isn't deprecated

0

i just added the sign self-destruction (you have to click on a sign to activate) and it was fixed thanks!!!

0

umm sorry but im first time on this website how i accept an answer or edit a question?

0

If I am not mistaken near the answer there is a button to accept

0

just found out how to edit it

0
0

shhhhiiiii*****........

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