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

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

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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

0
I need a real answer please! iipartyhat 25 — 9y
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. RoboFrog 400 — 9y
0
It already was a local script. and I do have debuggers on it.. iipartyhat 25 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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..

Answer this question