drakon-firestone

MainServer

Apr 1st, 2023
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. local players = game:GetService("Players")
  2.  
  3. local pets = game.ReplicatedFirst.Pets
  4. local playersFolder = workspace.Players
  5.  
  6. local createTemplate = game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("CreateTemplate")
  7.  
  8. players.PlayerAdded:Connect(function(player)
  9.     local folder = Instance.new("Folder")
  10.     folder.Name = player.Name
  11.     folder.Parent = playersFolder
  12.    
  13.     for i=1,20,1 do
  14.         --local newPet = pets[i]:Clone()
  15.         --newPet.Parent = folder
  16.         createTemplate:FireClient(player, pets[i].Name, i)
  17.     end
  18. end)
  19.  
  20.  
  21. game.ReplicatedStorage.Remotes.EquipPet.OnServerEvent:Connect(function(player, petName, id)
  22.     local petModel = game.ReplicatedFirst.Pets:FindFirstChild(petName):Clone()
  23.     petModel.Parent = workspace.Players:FindFirstChild(player.Name)
  24. end)
  25.  
  26. game.ReplicatedStorage.Remotes.UnequipPet.OnServerEvent:Connect(function(player, petName, id)
  27.     local playerFolder = workspace.Players:FindFirstChild(player.Name)
  28.     for i, pet in pairs(playerFolder:GetChildren()) do
  29.         if pet.Name == petName then
  30.             pet:Destroy()
  31.         end
  32.     end
  33. end)
Add Comment
Please, Sign In to add comment