Hi, so I have been trying to make a gmaepass that gives the player a pet for ages now and I have had no luck.
I need it so when the player buys a gamepass, it will spawn in a pet for them, and the pet will follow them around, and each time the log back in the pet will spawn again and follow them around.
Here is a link to the last time I asked this questions with no answers: https://scriptinghelpers.org/questions/38004/how-would-i-make-a-gamepass-that-gives-the-player-a-pet
This is the script I am trying to use to get the pet named "Cube", to follow the player.
repeat wait()until game.Players.LocalPlayer.Character print("Pet Controller Loaded!") function MovePet(pet, mode) local character = game.Players.LocalPlayer.Character local rpet = workspace.Cube local rmode = mode local inc = 0.7 if mode == true then local base = character["Head"] else 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("Cube",false) end
And this is the script I am trying to use to get the pet to only follow the player that owns it/has the gamepass.
local PassService = game:GetService("GamePassService") function spawnpet(c) local pet = game.ReplicatedService.Cube :Clone() 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,574089981) if check == true then spawnpet(char) end end) end)
Nothing has been working, I don't know what else to do, so if anyone could help that would be awesome, thanks.
More detailed explanation: When the player buys the gamepass, the pet that is linked to the gamepass will spawn next to them, from then on the pet will follow them, and if the die or rejoin, the pet will teleport back to them or spawn next to them. If two player buy the gamepass, each individual pet will know what player to follow, the player that bought them. Same thing goes for if there are more than two players with pets. The pet needs to know who to follow, I don't want it spawning in and then following someone else, it needs to follow only the player that bought it.
Nothing is working, it will not spawn when the gamepass is bought, it will not follow me with or without the gamepass, it will not spawn if I relog or reset, you might as well not have any scripts at all.
This is what it said in the output tab: 23:19:34.720 - Workspace.Sound.Script:1: attempt to index global 'sound' (a nil value) 23:19:34.720 - Stack Begin 23:19:34.721 - Script 'Workspace.Sound.Script', Line 1 23:19:34.721 - Stack End 23:19:34.820 - BarnSign is not a valid member of ServerScriptService 23:19:34.821 - Stack Begin 23:19:34.821 - Script 'ServerScriptService.Script', Line 2 23:19:34.822 - Stack End 23:19:36.329 - Game passes can only be queried by a Script running on a ROBLOX game server 23:19:36.591 - Unable to find module for asset id 23:19:36.592 - Stack Begin 23:19:36.592 - Script 'Workspace.Kohl's Admin Infinite.Credit', Line 1 23:19:36.592 - Stack End Pet Controller Loaded! 23:19:38.788 - Cube is not a valid member of Workspace
Okay, so I had "Cube", in ReplicatedStorage. So I changed that part of the script to this:
local PassService = game:GetService("GamePassService") function spawnpet(c) local pet = game.ReplicatedService.Cube :Clone() pet.Owner.Value = c pet.Parent = game.ReplicatedStorage pet.PrimaryPart.CFrame = c.LeftFoot.CFrame * CFrame.new(0,3,-2) end
But it still doesn't work.
Okay so I've now done this as well:
function MovePet(pet, mode) local character = game.Players.LocalPlayer.Character local rpet = ReplicatedStorage.Cube local rmode = mode local inc = 0.7 if mode == true then local base = character["Head"] else
Which got rid of the error of it not being able to find it in the Workspace. But then it came up with these errors:
00:02:00.740 - Tycoon.rbxl was auto-saved to C:/Users/Benjamin/Documents/ROBLOX/AutoSaves/Tycoon_AutoSave_0.rbxl 00:02:02.872 - Workspace.Sound.Script:1: attempt to index global 'sound' (a nil value) 00:02:02.873 - Stack Begin 00:02:02.873 - Script 'Workspace.Sound.Script', Line 1 00:02:02.874 - Stack End 00:02:04.278 - Game passes can only be queried by a Script running on a ROBLOX game server 00:02:04.576 - Unable to find module for asset id 00:02:04.577 - Stack Begin 00:02:04.577 - Script 'Workspace.Kohl's Admin Infinite.Credit', Line 1 00:02:04.578 - Stack End Pet Controller Loaded! 00:02:07.131 - Players.Player1.PlayerGui.PetController:6: attempt to index global 'ReplicatedStorage' (a nil value) 00:02:07.132 - Stack Begin 00:02:07.133 - Script 'Players.Player1.PlayerGui.PetController', Line 6 - global MovePet 00:02:07.133 - Script 'Players.Player1.PlayerGui.PetController', Line 26 00:02:07.134 - Stack End
I believe the problem is in the spawn pet function
here is what i saw: local pet = game.ReplicatedService.Cube :Clone() there should not be a space between cube and :clone() try that.