Make Part Attach To Player When Click Button

I have been trying to make a script which will give a pet to a player if they own the gamepass.
I have an inventory which shows the item (the pet) they have but im looking for when they click “Equip” it gives them the pet.

I had the code working so the pet would follow people around but that was on a server script and to everyone. Not just those who own the gamepass.

I currently have this piece of code -


			clone.Equipped.Visible = true
			clicks += 1

			local character = player.Character

			local pet = game.ReplicatedStorage.Pet2
						local humanrootpart = character.HumanoidRootPart
						local newpet = pet:clone()
			            newpet.Parent = character
						local bodyPos ="BodyPosition", newpet)
						bodyPos.MaxForce =, math.huge, math.huge)

						local bodyGyro ="BodyGyro", newpet)
						bodyGyro.MaxTorque =, math.huge, math.huge)

						while wait() do
							bodyPos.Position = humanrootpart.Position +,2,3)
							bodyGyro.CFrame = humanrootpart.CFrame

				clicks = 0
				clone.Equipped.Visible = false


I currently dont have the “Unequip” Function since the equip function doesnt even work.

I get no errors in my output when running the script but the pet does not appear when clicking equip.

Can anyone help? Thankyou!

1 Like

Is equip a variable or UI inside of the script? Stupid question, but someone probably made that mistake before.

1 Like

equip is the UI button inside of the inventory

Why didn’t anyone help? I’m trying to boost it. I don’t really know why it doesn’t work because I’m not good with that but seriously?