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!

7 comments

0

Is Crowns a name of a player?

0

The folder called ''Crowns'' does not exist

0

So, why do you have Crowns folder in Players Service?

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

1

Newfolder does not exist, you can try using WaitForChild or make sure the Crowns folder has been created.

0

ah yes, sorry i just tryped crowns there and i did not realise

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'