Herobrinekid2

LOCAL SCRIPT

Oct 10th, 2021 (edited)
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  1. local PLAYER = game.Players.LocalPlayer
  2. local PET = PLAYER:WaitForChild("EQUIPPED_PET", true)
  3. local PETS_LIST = require(game.ReplicatedStorage.PETS_LIST)
  4.  
  5.  
  6. local STEPPED = nil
  7. local POS = nil
  8. local GYR = nil
  9.  
  10. local function GET_PET(CHAR, NAME)
  11.     for _, v in pairs(CHAR:GetChildren()) do
  12.         if v:IsA("BasePart") and table.find(PETS_LIST, v.Name) then
  13.             return v
  14.         end
  15.     end
  16. end
  17.  
  18. local function GET_MOVERS(PET)
  19.     for _, v in pairs(PET:GetChildren()) do
  20.         warn(v.ClassName)
  21.         if v:IsA("BodyPosition") then
  22.             POS = v
  23.         end
  24.         if v:IsA("BodyGyro") then
  25.             GYR = v
  26.         end
  27.     end
  28.  
  29. end
  30.  
  31. PET.Changed:Connect(function(NAME)
  32.     local PET = GET_PET(PLAYER.Character, NAME)
  33.     print(PET)
  34.     if PET ~= nil then
  35.         GET_MOVERS(PET)
  36.         print(POS, GYR)
  37.         if STEPPED then
  38.             STEPPED:Disconnect()
  39.         end
  40.        
  41.         STEPPED = game:GetService("RunService").Stepped:Connect(function()
  42.             if PLAYER.Character.Humanoid.Health > 0 then
  43.                 local DEST = CFrame.new(PLAYER.Character.Head.CFrame * Vector3.new(1, 0, 2)).p
  44.                 local CF = PLAYER.Character.Head.CFrame
  45.  
  46.                 POS.Position = DEST
  47.                 print(POS.Position)
  48.                 GYR.CFrame = CF
  49.             else
  50.                 if STEPPED then
  51.                     STEPPED:Disconnect()
  52.                 end
  53.                 POS.MaxForce = Vector3.new(0, 0, 0)
  54.                 POS = nil
  55.                 GYR = nil
  56.             end
  57.         end)
  58.        
  59.        
  60.     end
  61. end)
Add Comment
Please, Sign In to add comment