Advertisement
DrawingJhon

Pet Follow Script

Jun 21st, 2020 (edited)
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. function givePet(player)
  2.     if player then
  3.         local char = player.Character
  4.         if char then
  5.             local pet = Instance.new("Part",workspace)
  6.             pet.Size = Vector3.new(1.5, 1.5, 1.5)
  7.             pet.TopSurface = Enum.SurfaceType.Smooth
  8.             pet.BottomSurface = Enum.SurfaceType.Smooth
  9.             pet.Material = Enum.Material.ForceField
  10.             pet.Anchored = false
  11.             pet.CanCollide = false
  12.             pet.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(Vector3.new(2, 2, 3))
  13.             pet.Name = "Pet"
  14.  
  15.             local humRootPart = char.HumanoidRootPart
  16.             pet.Parent = char
  17.             local bodyPos = Instance.new("BodyPosition", pet)
  18.             bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  19.  
  20.             local bodyGyro = Instance.new("BodyGyro", pet)
  21.             bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
  22.            
  23.             while wait() do
  24.                 local ps = humRootPart.CFrame * CFrame.new(Vector3.new(2, 2, 3))
  25.                 bodyPos.Position = ps.p
  26.                 bodyGyro.CFrame = humRootPart.CFrame
  27.             end
  28.         end
  29.     end
  30. end
  31. game.Players.JhonXD2006.CharacterAdded:Connect(function()
  32.     print("Player Added")
  33.     givePet(game.Players.JhonXD2006)
  34. end)
  35. givePet(game.Players.JhonXD2006)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement