Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local players = game:GetService("Players")
- local pets = game.ReplicatedFirst.Pets
- local playersFolder = workspace.Players
- local createTemplate = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("CreateTemplate")
- players.PlayerAdded:Connect(function(player)
- local folder = Instance.new("Folder")
- folder.Name = player.Name
- folder.Parent = playersFolder
- for i=1,20,1 do
- --local newPet = pets[i]:Clone()
- --newPet.Parent = folder
- createTemplate:FireClient(player, pets[i].Name, i)
- end
- end)
- game.ReplicatedStorage.Remotes.EquipPet.OnServerEvent:Connect(function(player, petName, id)
- local petModel = game.ReplicatedFirst.Pets:FindFirstChild(petName):Clone()
- petModel.Parent = workspace.Players:FindFirstChild(player.Name)
- end)
- game.ReplicatedStorage.Remotes.UnequipPet.OnServerEvent:Connect(function(player, petName, id)
- local playerFolder = workspace.Players:FindFirstChild(player.Name)
- for i, pet in pairs(playerFolder:GetChildren()) do
- if pet.Name == petName then
- pet:Destroy()
- end
- end
- end)
Add Comment
Please, Sign In to add comment