Failing to show give stats on GUI

script.Parent.MouseButton1Down:Connect(function(plr)

local cookies = plr:WaitForChild("Stats"):FindFirstChild("Cookies")

cookies.Value = cookies.Value + 1

end)

The error:
Players.topcst.PlayerGui.Main.Frame.Cookie.Handler:2: attempt to index number with ‘WaitForChild’

It is run by a normal script as i can avoid remote events and the issues they can cause. I know this is possible because i’ve done it before (inb4 someone says use remote events)

There is no player argument in MouseButton1Down. You can get the player by doing game.Players.LocalPlayer. Also, what is passed is the x and y, so they’re numbers, hence why you’re getting the error.

button.MouseButton1Down:Connect(function(x, y)

    print(x, y)

end)

https://developer.roblox.com/en-us/api-reference/event/GuiButton/MouseButton1Down

EDIT: Nvm, you said it’s not a local script, but the parameters was the issue.

The problem happens because Cookies is not a valid member.

And what @TheCarbyneUniverse said.

Edit: If this is a local script, you can just access the GUI from the LocalPlayer.

Its not a local script, ill do what i did before script.Parent.Parent.Parent etc to get the player