I have been trying to make a pet that spawns when a player buys a gamepass and follows the player with the gamepass, and that specific person, so two people can have a pet at the same time if they buy the gamepass. This is what I have so far, and its not really working, nor do I know how to make it spawn and follow the person when the have the gamepass.
repeat wait()until game.Players.LocalPlayer.Character print("Pet Controller Loaded!") function MovePet(pet, mode) local character = game.Players.LocalPlayer.Character local rpet = workspace.Pet local rmode = mode local inc = 0.7 if mode == true then -- If this is true then make the pet float local base = character["Head"] else -- If its anything else other than true then make the pet go on the ground local base = character.LeftFoot local dir = CFrame.new(rpet.Position, base.Position).lookVector print(dir) for i=0,10,2 do rpet.CFrame = rpet.CFrame + (dir * inc) wait(0.05) end end end while wait()do MovePet("Pet",false) end
If anyone could tell me how to fix this, that would be great! That's if you understand what I am trying to say haha.
Just put this in a script in serverscriptservice and make sure your pet is in ReplicatedStorage and has an ObjectValue name Owner or something.
local PassService = game:GetService("GamePassService") function spawnpet(c) local pet = game.ReplicatedService.x :Clone()--x = pet name pet.Owner.Value = c pet.Parent = game.Workspace pet.PrimaryPart.CFrame = c.LeftFoot.CFrame * CFrame.new(0,3,-2) end game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(char) local check = PassService:PlayerHasPass(player,Id) --Id = gamepass id if check == true then spawnpet(char) end end) end)
Like I've mentioned earlier I haven't worked with gamepasses yet, but this should work.