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

This findFirstChild syntax is skipping the if statement in the loop!.Please help?

it skips the if statement in the while loop and i dont know why

check = true

> script.Parent.MouseButton1Click:connect(function()
	--if game.Players.LocalPlayer.Backpack:findFirstChild("Fishing Rod") then
print("hmm")
> while check do wait()
print("We've entered the loop >:)")
> if game.Players.LocalPlayer.Backpack:findFirstChild("Fishing rod") then
print("were in!")
game.Players.LocalPlayer.Backpack:findFirstChild("Fishing rod"):remove()
else
check = false	
end
end
print("Done, movin on")
--end
end)

2 answers

It's simple. Make it at a LocalScript and put it at the SarterGui or at the StarterPack.

3 comments

0

I need a real answer please!

0

If this isn't in a local script, then Nano is right. LocalPlayer fails to do anything if it's not a local script. If it is, try placing a print(game.Players.LocalPlayer.Backpack:findFirstChild("Fishing rod")) to see if it's a correct path.

0

It already was a local script. and I do have debuggers on it..

nvm i got it all it took was

script.Parent.MouseButton1Click:connect(function()
	game.Players.LocalPlayer.PlayerGui.buyfx:Play()
	if script.Parent.Parent.description.Text == "Gold fish" and game.Players.LocalPlayer.Backpack:findFirstChild("Gold fish") then
repeat game.Players.LocalPlayer.Backpack:findFirstChild("Gold fish"):remove() game.Players.LocalPlayer.gamestats.m.Value=game.Players.LocalPlayer.gamestats.m.Value+10 until game.Players.LocalPlayer.Backpack:findFirstChild("Gold fish") == nil

easy..

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