Hey, guys so I’m having an issue with the buy pet script. I have tried to change the PetShop frames, and renaming them, as well as changing some of the functions in the script but nothing is seeming to work. I have an output message and it looks like this…
I obviously have a Folder named “Pets” with the pets in them, I’m not yet having issues with the pet going behind me, but equipping it first. I also have a RemotesFunctions folder…
I have the script I typed below
Equip Pet Script
script.Parent.MouseButton1Click:Connect(function()
local result = game.ReplicatedStorage.RemoteFunctions.EquipPet:InvokeServer(script.Parent.Parent.Name)
end)
Main Script – Including leaderboards, and the Rigidity to follow the player
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new('Folder', player)
leaderstats.Name = 'leaderstats'
local Pets = Instance.new('Folder', player)
Pets.Name = 'Pets'
local coins = Instance.new('IntValue', leaderstats)
coins.Name = 'Coins'
coins.Value = 5000
player.CharacterAdded:Connect(function(char)
local attachment = Instance.new('Attachment', char.HumanoidRootPart)
attachment.Name = 'CharacterAt'
end)
end)
game.ReplicatedStorage.Remotes.Add.OnServerEvent:Connect(function(player, ammount)
local currency = 'Coins'
player.leaderstats[currency].Value = player.leaderstats[currency].Value + ammount
end)
game.ReplicatedStorage.RemoteFunctions.EquipPet.OnServerInvoke = function(player, pet)
local currency = 'Coins'
local MainPet = game.ServerStorage.Pets:FindFirstChild(pet)
if not player.Pets:FindFirstChild(MainPet.Name) then
if player.leaderstats[currency].Value >= MainPet.Parent.Value then
player.leaderstats[currency].Value = player.leaderstats[currency].Value - MainPet.Price.Value
local clonedPet = MainPet:Clone()
clonedPet.Parent = player.Character
clonedPet:SetPrimaryPartCFrame(player.Character.Head.CFrame)
local atPet = Instance.new('Attachment', clonedPet.PrimaryPart)
local ap = Instance.new('AlignPosition')
ap.Parent = clonedPet
ap.RigidityEnabled = true
ap.Attachment0 = atPet
ap.Attachment1 = player.Character.HumanoidRootPart.CharacterAt
return 'Bought'
else
return 'Not enough coins'
end
else
return 'Equip'
end
end
if you guys have any solutions or anyway I can try and fix this please tell me!
Wait I am confused. The image that is showing the error is saying that the error is occuring on line 2 in a LocalScript…? And I am pretty sure I have found the actual code line that is causing the error
The problem here is that the MainPet’s parent is the folder named Pets, and you are trying to say that there is a Value property. But there is no Value property for Folder instances. So the script will assume that Value is a child of the folder.
Thanks! The buying part worked, but when I equip the pet it launches my body on the floor like an ice rank, ill get back to you when I try and get this bug fixed.
If he helped you fix your issue you should mark it as a solution so other people will know where to look if they have a similar issue as you, as well as for the guy to benefit by it in his own ways.