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)

if You Have Any Idea On Why This Is Happening Please Tell Me And I Will Respond As Soon As Possible Thank You!

3 comments

0

Check the hierarchy of the "player" object while your game is running. Is "coins" in a folder, or directly under the player?

0

On line 6, it's saying that the Newfolder variable is equal to nil, aka nothing, meaning that on line 2, there wasn't a folder found in game.Players called "Coins." Were you trying to look into a player, and not the players service?

0

sorry for late reply but, maybe the script that makes the "Coins" folder is delaying so i will try to move or add a wait before the line of "NewFolder" also i will try to use "WaitForChild" and ill try to check if its there using if statements after the variable of "Coins" Thanks!