Advertisement
giganciprogramowania

l3 petsClient

Mar 3rd, 2023
1,115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. local runService = game:GetService("RunService")
  2.  
  3.  
  4. local playersFolder = workspace:WaitForChild("Players")
  5.  
  6.  
  7. local petsPerRow = 5
  8.  
  9.  
  10. local offsetX = 4
  11. local offsetZ = 5
  12. local offsetPlayer = 6
  13.  
  14.  
  15. local function positionPets(character, playerFolder, deltaTime, sin, cos)
  16. local petCount = #playerFolder:GetChildren()
  17. local rows = math.ceil(petCount / petsPerRow)
  18.  
  19.  
  20. for i, pet in pairs(playerFolder:GetChildren()) do
  21. local row = math.floor( (i - 1) / petsPerRow)
  22. local col = (i - 1) % petsPerRow
  23.  
  24. local characterSize = character:GetExtentsSize()
  25. local petSize = pet:GetExtentsSize()
  26. local petsInRow = math.min(petCount - row * petsPerRow, petsPerRow)
  27.  
  28. local x = (col - petsInRow/2 + 0.5) * offsetX
  29. local y = petSize.Y/2 - characterSize.Y/2
  30. local z = (row * offsetZ) + offsetPlayer
  31.  
  32.  
  33. if character.Humanoid.MoveDirection.Magnitude > 0 then
  34. if pet:FindFirstChild("Walks") then
  35. pet:SetPrimaryPartCFrame(pet.PrimaryPart.CFrame:Lerp(
  36. character.PrimaryPart.CFrame * CFrame.new(x, y + sin, z) * CFrame.fromEulerAnglesXYZ(0,0,cos),0.1))
  37. elseif pet:FindFirstChild("Flying") then
  38. pet:SetPrimaryPartCFrame(pet.PrimaryPart.CFrame:Lerp(
  39. character.PrimaryPart.CFrame * CFrame.new(x, y / 2 +math.sin(time()*3)+1, z), 0.1))
  40. end
  41. else
  42. if pet:FindFirstChild("Walks") then
  43. pet:SetPrimaryPartCFrame(pet.PrimaryPart.CFrame:Lerp(
  44. character.PrimaryPart.CFrame * CFrame.new(x, y, z) ,0.1))
  45. elseif pet:FindFirstChild("Flying") then
  46. pet:SetPrimaryPartCFrame(pet.PrimaryPart.CFrame:Lerp(
  47. character.PrimaryPart.CFrame * CFrame.new(x, y / 2 + math.sin(time()*3)+1, z) , 0.1))
  48. end
  49. end
  50. end
  51. end
  52.  
  53.  
  54. runService.RenderStepped:Connect(function(deltaTime)
  55. local sin = (math.sin(15 * time() + 1.6)/.5)+1
  56. local cos = math.cos(7 * time() + 1) / 4
  57.  
  58.  
  59. for i, playerFolder in pairs(playersFolder:GetChildren()) do
  60. local player = game.Players:FindFirstChild(playerFolder.Name)
  61. if player ~= nil then
  62. local character = player.Character or nil
  63. if character ~= nil then
  64. positionPets(character, playerFolder, deltaTime, sin, cos)
  65. end
  66. end
  67. end
  68. end)
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement