Previized

ServerScript ("Stats")

Nov 14th, 2020 (edited)
1,166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.88 KB | None | 0 0
  1. --@author FiredDusk (aka Previized)
  2.  
  3. --// Remotes
  4. local ShootWeb = game.ReplicatedStorage:WaitForChild('ShootWeb')
  5. local RemoveWeb = game.ReplicatedStorage:WaitForChild('RemoveWeb')
  6. local ClimbUpWeb = game.ReplicatedStorage:WaitForChild('ClimbUpWeb')
  7. local ClimbDownWeb = game.ReplicatedStorage:WaitForChild('ClimbDownWeb')
  8. local AddForce = game.ReplicatedStorage:WaitForChild('AddForce')
  9.  
  10. --// Stats Handler
  11. game.Players.PlayerAdded:Connect(function(Player)
  12.     local Prefix = 'user_'..tostring(Player.UserId)
  13.    
  14.     --// Player Stats (leaderboard)
  15.     local Stats = Instance.new('Folder',Player)
  16.     Stats.Name = 'leaderstats'
  17.  
  18.     local Speed2 = Instance.new('IntValue',Stats)
  19.     Speed2.Name = 'Speed'
  20.     Speed2.Value = 0
  21.    
  22.     --// Character Added   
  23.     Player.CharacterAdded:Connect(function(Character)
  24.         spawn(function()
  25.             while wait(1) do
  26.                 for i,v in pairs(Character:GetChildren()) do
  27.                     if v:IsA('Shirt') then
  28.                         v.ShirtTemplate = 'rbxassetid://811703916' -- Spider-man shirt
  29.                     elseif v:IsA('Pants') then
  30.                         v.PantsTemplate = 'rbxassetid://816000903' -- Spider-man pants
  31.                     end
  32.                 end
  33.             end
  34.         end)
  35.        
  36.  
  37.         while wait() do
  38.             if Character:FindFirstChild('HumanoidRootPart') then
  39.                 Speed2.Value = math.floor(Character.HumanoidRootPart.Velocity.magnitude)
  40.             end
  41.         end
  42.  
  43.     end)
  44. end)
  45.  
  46. --// Remote Handler
  47. ShootWeb.OnServerEvent:Connect(function(Player,Request,MousePos)
  48.     if Request == 'ShootWeb' then
  49.         local Part = Instance.new('Part',workspace.AttatchmentParts)
  50.         Part.Name = Player.Name
  51.         Part.Size = Vector3.new(1,1,1)
  52.         Part.Transparency = 1
  53.         Part.Anchored = true
  54.         Part.CanCollide = false
  55.         Part.CFrame = CFrame.new(MousePos)
  56.        
  57.         local Att0 = Instance.new('Attachment',Player.Character.LeftHand)
  58.         local Att1 = Instance.new('Attachment',Part)
  59.        
  60.         Rope = Instance.new('RopeConstraint',Player.Character.LeftHand)
  61.         Rope.Color = BrickColor.new('Institutional white')
  62.         Rope.Visible = true
  63.         Rope.Length = (Player.Character.LeftHand.Position - Part.Position).magnitude
  64.         Rope.Attachment0 = Att0
  65.         Rope.Attachment1 = Att1
  66.        
  67.     end
  68. end)
  69.  
  70. RemoveWeb.OnServerEvent:Connect(function(Player,Request)
  71.     if Request == 'RemoveWeb' then
  72.         local Character = Player.Character
  73.         local HumanoidRP = Character:FindFirstChild('HumanoidRootPart')
  74.         local LeftHand = Character:FindFirstChild('LeftHand')
  75.         for i,v in pairs(LeftHand:GetChildren()) do
  76.             if v:IsA('RopeConstraint') then
  77.                 v:Destroy()
  78.             end
  79.         end
  80.         for i,v in pairs(workspace.AttatchmentParts:GetChildren()) do
  81.             if v:IsA('Part') then
  82.                 if v.Name == Player.Name then
  83.                     v:Destroy()
  84.                 end
  85.             end
  86.         end
  87.     end
  88. end)
  89.  
  90. --// Climb Up
  91. ClimbUpWeb.OnServerEvent:Connect(function(Player,Request,Climbing,OppositeDeb)
  92.     local ClimbingWeb = Climbing
  93.     if Request == 'Start' then
  94.         local Character = Player.Character
  95.         local HumanoidRP = Character:FindFirstChild('HumanoidRootPart')
  96.         local LeftHand = Character:FindFirstChild('LeftHand')
  97.         if LeftHand:FindFirstChild('RopeConstraint') then
  98.             ClimbingWeb = Climbing
  99.             while ClimbingWeb == true and LeftHand:FindFirstChild('RopeConstraint') do
  100.                 Rope.Length = Rope.Length - 3
  101.                 game:GetService('RunService').Heartbeat:Wait()
  102.             end
  103.         end
  104.     elseif Request == 'Stop' then
  105.         ClimbingWeb = Climbing
  106.     end
  107. end)
  108.  
  109. --// Climb Down
  110. ClimbDownWeb.OnServerEvent:Connect(function(Player,Request,Climbing,OppositeDeb)
  111.     local HoldingE
  112.     local ClimbingWeb = Climbing
  113.     if Request == 'Start' then
  114.         local Character = Player.Character
  115.         local HumanoidRP = Character:FindFirstChild('HumanoidRootPart')
  116.         local LeftHand = Character:FindFirstChild('LeftHand')
  117.         if LeftHand:FindFirstChild('RopeConstraint') then
  118.             ClimbingWeb = Climbing
  119.             while ClimbingWeb == true and LeftHand:FindFirstChild('RopeConstraint') do
  120.                 Rope.Length = Rope.Length + 3
  121.                 game:GetService('RunService').Heartbeat:Wait()
  122.             end
  123.         end
  124.     elseif Request == 'Stop' then
  125.         ClimbingWeb = Climbing
  126.     end
  127. end)
  128.  
Add Comment
Please, Sign In to add comment