I'm making my own game, and I need a pet to be added to the player when the button is pressed. I get an error. Please help me figure it out! My script: script.Parent.MouseButton1Click:connect(function(Player) local PetInv = Player:WaitForChild("Pets") PetInv:WaitForChild(1).Value = PetInv:WaitForChild(1).Value +1 end)
You aren't declaring what "Player" is you need to get the player through game.Players.localplayer (for local scripts) or other means for server scripts (e.g. :GetPlayerFromCharacter)
I'm in mobile at the moment so it's a bit trickier to provide links and useful code but that should get you started! Let me know if it helped :) good luck!
Try this:
local PetInv = Player.Pets PetInv:WaitForChild('1') script.Parent.MouseButton1Click:Connect(function(Player) PetInv.Value += 1 end)