Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
hvcu 3
5 years ago
Edited 5 years ago
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)

0
i also have an leaderboard. hvcu 3 — 5y
0
Change "GetChildren" to "findFirstChild" in the first line ChiefWildin 295 — 5y
0
ok ill try hvcu 3 — 5y
0
No. Just learn Lua tbh. User#6546 35 — 5y
View all comments (7 more)
0
Workspace.Sign.Text.Script:10: attempt to index global 'PLR' (a nil value) 21:55:35.167 - Stack Begin hvcu 3 — 5y
0
OOOFFFF hvcu 3 — 5y
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() User#25448 0 — 5y
0
That is if it's a ServerScript, also instead of using a StringValue from workspace, just call it through "" User#25448 0 — 5y
0
ill have to explain everything to fix this problem. hvcu 3 — 5y
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 ChiefWildin 295 — 5y
0
kid? I am an angry teenager hvcu 3 — 5y

1 answer

Log in to vote
1
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 years ago

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.

0
you are the best you made me cry xd hvcu 3 — 5y
0
If solved your problems, accept answer or put [SOLVED] in title. yHasteeD 1819 — 5y
0
:connect isn't deprecated User#25448 0 — 5y
View all comments (6 more)
0
i just added the sign self-destruction (you have to click on a sign to activate) and it was fixed thanks!!! hvcu 3 — 5y
0
umm sorry but im first time on this website how i accept an answer or edit a question? hvcu 3 — 5y
0
If I am not mistaken near the answer there is a button to accept yHasteeD 1819 — 5y
0
just found out how to edit it hvcu 3 — 5y
0
https://imgur.com/a/ce1GGD0 works perfect hvcu 3 — 5y
0
shhhhiiiii*****........ User#25448 0 — 5y
Ad

Answer this question