You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to be able to get passed this script error that has been blocking my progress -
What is the issue? Include screenshots / videos if possible!
I haven’t looked for many solutions
Pet folder
Local Script Location
Main script and pet location
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new('Folder', player)
leaderstats.Name = 'leaderstats'
local Pet = Instance.new('Folder', player)
Pet.Name = 'Pet'
local coins = Instance.new("IntValue", leaderstats)
coins.Name = 'Coins'
coins.Value = 0
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)
local currency = 'Coins'
local ammount = 1
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.Pet:FindFirstChild(MainPet.Name) then
if player.leaderstats[currency].Value >= MainPet.Price.Value then
player.leaderstats[currency].Value = player.leaderstats[currency].Value - MainPet.Price.Value
local clonedPet = MainPet:Clone()
local atPet = Instance.new("Attachment", clonedPet.PrimaryPart)
local ap = Instance.new ("AlignPosition")
ap.Parent = pet
ap.RigdigityEnabled = true
clonedPet.Parent = player.Character
clonedPet:SetPrimaryPartCFrame(player.Character.Head.Cframe)
ap.Attachment0 = atPet
ap.Attachment1 = player.Character.HumanoidRootPart.CharacterAt
return "Bought"
else
return "Not enough coins"
end
else
return "Equip"
end
end
This is the local script it connects to
script.Parent.MouseButton1Click:Connect(function()
local result = game.ReplicatedStorage.RemoteFunctions.EquipPet:InvokeServer(script.Parent.Parent.Name)
end)