Guest User

Untitled

a guest
Apr 21st, 2020
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.87 KB | None | 0 0
  1. --Services--
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3. local ServerStorage = game:GetService("ServerStorage")
  4. local Players = game:GetService('Players')
  5.  
  6. --Variables--
  7. local Throw = ReplicatedStorage:WaitForChild("Throw")
  8. local Select = ReplicatedStorage:WaitForChild("Select")
  9. local changeAppearance = ReplicatedStorage:WaitForChild('changeAppearance')
  10. local HatFolder = ServerStorage.Hats
  11. local HitboxFolder = ServerStorage.Hitboxes
  12.  
  13. --humanoidDescrition--
  14. local Birthday = Instance.new("HumanoidDescription")
  15. Birthday.Face = 1428416217
  16. Birthday.HeadColor = Color3.new(211,190,150)
  17. Birthday.LeftArmColor = Color3.new(245,205,49)
  18. Birthday.RightArmColor = Color3.new(245,205,49)
  19. Birthday.LeftLegColor = Color3.new(164,189,71)
  20. Birthday.RightLegColor = Color3.new(164,189,71)
  21. Birthday.TorsoColor = Color3.new(167,94,155)
  22.  
  23. --Script--
  24. Select.OnServerEvent:Connect(function(player, hatName)
  25.    
  26.     local character = player.Character
  27.     local hat = HatFolder:FindFirstChild(hatName)
  28.    
  29.     if hat then
  30.  
  31.         player.Character.Humanoid:ApplyDescription(Birthday) --Change Their Avatar To The Selected Character
  32.         --[[HIT BOXES (different sizes because there are 3 different sized characters small, medium and big)
  33.         if hat.Name == "Cole" then
  34.            
  35.             local Hitbox = HitboxFolder:FindFirstChild("HitboxBig")
  36.             local clonedHitbox = Hitbox:Clone()
  37.             clonedHitbox.CFrame = character.HumanoidRootPart.CFrame
  38.             Hitbox.Name = "Hitbox"
  39.             local hitboxWeld = Instance.new("WeldConstraint")
  40.             hitboxWeld.Part0 = clonedHitbox
  41.             hitboxWeld.Part1 = character.HumanoidRootPart
  42.             hitboxWeld.Parent = clonedHitbox
  43.             clonedHitbox.Parent = character
  44.            
  45.         elseif hat.Name == "CaptainHat" then
  46.            
  47.             local Hitbox = HitboxFolder:FindFirstChild("HitboxSmall")
  48.             local clonedHitbox = Hitbox:Clone()
  49.             clonedHitbox.CFrame = character.HumanoidRootPart.CFrame
  50.             Hitbox.Name = "Hitbox"
  51.             local hitboxWeld = Instance.new("WeldConstraint")
  52.             hitboxWeld.Part0 = clonedHitbox
  53.             hitboxWeld.Part1 = character.HumanoidRootPart
  54.             hitboxWeld.Parent = clonedHitbox
  55.             clonedHitbox.Parent = character
  56.            
  57.         else           
  58.             local Hitbox = HitboxFolder:FindFirstChild("HitboxNormal")
  59.             local clonedHitbox = Hitbox:Clone()
  60.             clonedHitbox.CFrame = character.HumanoidRootPart.CFrame
  61.             Hitbox.Name = "Hitbox"
  62.             local hitboxWeld = Instance.new("WeldConstraint")
  63.             hitboxWeld.Part0 = clonedHitbox
  64.             hitboxWeld.Part1 = character.HumanoidRootPart
  65.             hitboxWeld.Parent = clonedHitbox
  66.             clonedHitbox.Parent = character
  67.            
  68.         end    
  69.         --]]
  70.                    
  71.         local chosenHat = HatFolder:FindFirstChild(hat.Name)
  72.         local clonedHat = chosenHat:Clone()
  73.         clonedHat.Name = "Hat"
  74.         local head = character:WaitForChild("Head")
  75.         clonedHat.CFrame = head.CFrame * CFrame.new(0,1.5,0)
  76.         clonedHat.Parent = character
  77.        
  78.         --Weld The Hat To The Players Head
  79.         local weld = Instance.new("WeldConstraint")
  80.         weld.Name = "Weld"
  81.         weld.Part0 = clonedHat
  82.         weld.Part1 = head
  83.         weld.Parent = clonedHat
  84.        
  85.         --Picking The Hat Up--
  86.         clonedHat.Touched:Connect(function(hit)
  87.  
  88.             if hit.Name == "Left Leg" or hit.Name == "Right Leg" then
  89.    
  90.                 if hit:IsDescendantOf(character) then
  91.                    
  92.                     weld.Parent = clonedHat
  93.                    
  94.                 elseif not hit:IsDescendantOf(character) then
  95.                            
  96.                         local opponent = Players:GetPlayerFromCharacter(hit.Parent)
  97.                        
  98.                         if opponent then
  99.                             if hit.Parent ~= character then
  100.                                 else
  101.                             character:BreakJoints()
  102.                             wait(5)
  103.                             opponent.leaderstats.Points.Value = opponent.leaderstats.Points.Value + 1
  104.                            
  105.                             end
  106.                         end
  107.                     end
  108.                 end
  109.             end)
  110.                    
  111.     end
  112. end)
  113.  
  114. --Throwing The Hat--
  115. Throw.OnServerEvent:Connect(function(player, mouse)
  116.    
  117.     local character = player.Character
  118.     local clonedHat = character:FindFirstChild("Hat")
  119.     local weld = clonedHat:FindFirstChild("Weld")
  120.     local trail = Instance.new("Trail")
  121.     local att0 = Instance.new("Attachment")
  122.     local att1 = Instance.new("Attachment")
  123.    
  124.     if weld then
  125.         weld.Parent = nil
  126.        
  127.         local bodyVelocity = Instance.new("BodyVelocity")
  128.        
  129.         --Moving The Hat Forward--
  130.         bodyVelocity.MaxForce = Vector3.new(500,500,500)
  131.         bodyVelocity.Velocity = (character.HumanoidRootPart.CFrame.lookVector*25)
  132.         --bodyVelocity.Velocity = mouse.p
  133.         bodyVelocity.Parent = character:FindFirstChild("Hat")
  134.        
  135.         --Trail Effect On Hat--
  136.         trail.Parent = clonedHat
  137.         att0.Parent = clonedHat
  138.         att1.Parent = clonedHat
  139.         trail.Attachment0 = att0
  140.         trail.Attachment1 = att1
  141.         trail.Enabled = true
  142.         att0.Position = Vector3.new(.5,0,0)
  143.         att1.Position = Vector3.new(-.5,0,0)
  144.        
  145.         local touchConn
  146.        
  147.         touchConn = clonedHat.Touched:Connect(function(hit)
  148.             if hit.Parent:FindFirstChild("Humanoid") then
  149.                 if hit.Parent.Name ~= player.Name then
  150.                     hit.Parent:FindFirstChild("Hat").Weld.Parent = nil
  151.                    
  152.                     end
  153.                 end
  154.             end)
  155.        
  156.         wait(3)
  157.         bodyVelocity:Destroy()
  158.         trail.Enabled = false
  159.        
  160.     end
  161. end)
Advertisement
Add Comment
Please, Sign In to add comment