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

help with attempt to index nil with 'FindFirstChild'?

Asked by 3 years ago
Edited 3 years ago

so i made a code that should print out "What" but it does not and what error prints out? attempt to index nil with 'FindFirstChild' so it means that the "FindFirstChild" has a problem

NOTE: just to clarify i rewrote my whole script and i did not notice but i wrote "Crowns" but i was supposed to write "Coins" but even if i correct the code and i try it in a new fresh game it still does not work.

here is my code:

print("gygfg")
local Newfolder = game.Players:FindFirstChild("Coins")
print("uhm")
game.Players.PlayerAdded:Connect(function(plr)
    print("if")
    if Newfolder:FindFirstChild("Coins") then
        print("What")
    else
        print("No Coins Value Found")
    end
end)

Thanks!

0
Is Crowns a name of a player? BestCreativeBoy 1395 — 3y
0
The folder called ''Crowns'' does not exist Bankrovers 226 — 3y
0
So, why do you have Crowns folder in Players Service? BestCreativeBoy 1395 — 3y
0
Also, please clarify that the Folder named, 'Crowns' and 'Coins' value exist in the game at the location where you directing the script to BestCreativeBoy 1395 — 3y
View all comments (3 more)
1
`Newfolder` does not exist, you can try using [WaitForChild](https://developer.roblox.com/en-us/api-reference/function/Instance/WaitForChild) or make sure the `Crowns` folder has been created. imKirda 4491 — 3y
0
ah yes, sorry i just tryped crowns there and i did not realise Rgboffical_yt 40 — 3y
0
j just to clarify i rewrote my whole script and i did not notice but i wrote "Crowns" but i was supposed to write "Coins" but even if i correct the code and i try it in a new fresh game it still does not work and it still errors the same error                         ServerScriptService.Script:6: attempt to index nil with 'FindFirstChild' Rgboffical_yt 40 — 3y

Answer this question