Advertisement
DrawingJhon

Floater hat

Aug 17th, 2022 (edited)
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.58 KB | None | 0 0
  1. local HumanDied = false
  2. local plr = game:GetService("Players").LocalPlayer
  3. local char = plr.Character
  4. local parts = {}
  5.  
  6. local netless = game:GetService("RunService").Heartbeat:Connect(function()
  7.     for i, v in pairs(parts) do
  8.         if v:IsA("BasePart") then
  9.             v.AssemblyLinearVelocity = Vector3.new(-30,0,0)
  10.         end
  11.     end
  12.     sethiddenproperty(plr,"MaximumSimulationRadius",math.huge)
  13.     sethiddenproperty(plr,"SimulationRadius",999999999)
  14. end)
  15.  
  16. local function create(part, parent, p, r)
  17.     local att0 = Instance.new("Attachment", part)
  18.     local att1 = Instance.new("Attachment", parent)
  19.     local alignPos = Instance.new("AlignPosition", part)
  20.     local alignOr = Instance.new("AlignOrientation", part)
  21.    
  22.     att1.Position = p or Vector3.new()
  23.     att1.Orientation = r or Vector3.new()
  24.  
  25.     alignPos.Attachment0 = att0
  26.     alignPos.Attachment1 = att1
  27.     alignPos.MaxForce = 999999999
  28.     alignPos.MaxVelocity = math.huge
  29.     alignPos.ReactionForceEnabled = false
  30.     alignPos.Responsiveness = math.huge
  31.     alignPos.RigidityEnabled = false
  32.  
  33.     alignOr.Attachment0 = att0
  34.     alignOr.Attachment1 = att1
  35.     alignOr.Responsiveness = math.huge
  36.     alignOr.MaxTorque = 999999999
  37. end
  38.  
  39. local part = Instance.new("Part", plr.Character)
  40. part.CanCollide = false
  41. part.Size = Vector3.new(1,1,1)
  42. part.Position = plr.Character:GetPivot().Position + Vector3.new(0, 3, 0)
  43. part.Transparency = 0.8
  44. local bv = Instance.new("BodyVelocity", part)
  45. bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  46. bv.Velocity = Vector3.new()
  47.  
  48. local mouse = plr:GetMouse()
  49.  
  50. function GetHit()
  51.     local unitRay = mouse.UnitRay
  52.     local params = RaycastParams.new()
  53.     params.FilterDescendantsInstances = {plr.Character, part, unpack(parts)}
  54.     params.FilterType = Enum.RaycastFilterType.Blacklist
  55.     local ray = workspace:Raycast(unitRay.Origin, unitRay.Direction * 99999, params)
  56.     return ray
  57. end
  58.  
  59. local objects = {}
  60.  
  61. local function AddHat(obj)
  62.     obj:BreakJoints()
  63.     table.insert(parts, obj)
  64.        
  65.     create(obj, part, Vector3.new(0, 0.5, 0))
  66. end
  67.  
  68. if plr.Character:findFirstChild("Appearance") then
  69. for i, obj in pairs(plr.Character.Appearance:GetChildren()) do
  70.     if obj:FindFirstChild("Mesh") and obj:FindFirstChild("Head") then
  71.         AddHat(obj.Mesh)
  72.     end
  73. end
  74. end
  75.  
  76. for i, obj in pairs(plr.Character:GetChildren()) do
  77.     if obj:IsA("Accoutrement") then
  78.         --AddHat(obj.Handle)
  79.     end
  80. end
  81.  
  82. local rs = game:GetService("RunService").Heartbeat:Connect(function()
  83.     local hit = GetHit()
  84.     if hit then
  85.         part.Position = hit.Position
  86.     end
  87. end)
  88.  
  89. local died; died = plr.Character.Humanoid.Died:Connect(function()
  90.     netless:Disconnect()
  91.     died:Disconnect()
  92.     rs:Disconnect()
  93. end)
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement