I’m trying to work on a pet system but for some reason the pet wont parent to the character, does anyone know why?
Local Script in text button:
local repStor = game:GetService("ReplicatedStorage")
local dog = repStor:WaitForChild("Pets"):FindFirstChild("Dog")
local hasPet = repStor:WaitForChild("Pets"):FindFirstChild("HasPet")
local purchaseEvent = repStor:WaitForChild("Pets"):FindFirstChild("PurchasePet")
local player = game.Players.LocalPlayer
local stat = player:WaitForChild("leaderstats")
local cash = stat:FindFirstChild("Cash")
script.Parent.MouseButton1Down:Connect(function()
if cash.Value >= 500000 and hasPet.Value == false then
cash.Value -= 500000
player.PlayerGui.Shop.MainBack.PetFrame.Dog.Cost.Text = "Purchased"
player.PlayerGui.Shop.MainBack.PetFrame.Dog.Cost.TextColor3 = Color3.fromRGB(32, 218, 0)
local purchasedPet = "Dog"
purchaseEvent:FireServer(purchasedPet, print(purchasedPet))
end
end)```
Server Script in SSS:
```lua
local repStor = game:GetService("ReplicatedStorage")
local petEvent = repStor:WaitForChild("Pets"):FindFirstChild("PurchasePet")
local petFolder = repStor:WaitForChild("Pets")
petEvent.OnServerEvent:Connect(function(player, petName)
local petToEquip = petFolder:FindFirstChild(petName)
wait(0.5)
petToEquip.Parent = player.Character.HumanoidRootPart
print(petToEquip.Parent)
end)
The issue is right here, you get the dog object from the pets folder but, you need to use :Clone() so you can parent that new clone to the player character
you can just add :Clone() after defining local petToEquip
No it still doesn’t work. It prints the parent as Humanoid Root Part but it doesnt appear in the character when you go into the explorer whilst you are playing.
i believe you have to parent the pet to the character object instead of the humanoid root part but im not 100% sure on that you can try it for yourself or atleast thats what i do when i add an accesory to a character such a backpack or so.
I have never tried doing a pet so i can’t tell if its the same.