I want to make a part where you touch it, it gives you a pet.
I’ve tried everything and it keeps saying Attempt to nil index ‘PetInventory’
``local player = game.Players.LocalPlayer
local pets = player.PetInventory
script.Parent.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum ~= nil then
local rat = Instance.new("StringValue")
rat.Name = "Rat"
rat.Parent = script.Parent
local ratClone = rat:Clone()
ratClone.Parent = pets
end
end)