Advertisement
giganciprogramowania

l4 MainServer

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