Advertisement
rblxdevofficial

Simulator Series Part 5 leaderstats

Mar 24th, 2022
4,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. local players = game:GetService("Players")
  2.  
  3. local function UpdatePlayerSize(player)
  4.     local leaderstats = player:WaitForChild("leaderstats")
  5.     local strength = leaderstats:WaitForChild("Strength")
  6.     local storage = player:WaitForChild("Storage")
  7.    
  8.     local scale = ((strength.Value/storage.Value)*100)
  9.     if strength.Value == 0 then
  10.         scale = 1
  11.         player.CameraMaxZoomDistance = 128
  12.         player.CameraMinZoomDistance = 0.5
  13.         workspace.SellPart.Attachment.SellPrompt.MaxActivationDistance = scale*10
  14.     else
  15.         workspace.SellPart.Attachment.SellPrompt.MaxActivationDistance = scale*10
  16.         player.CameraMaxZoomDistance = scale*10
  17.         player.CameraMinZoomDistance = scale*2
  18.     end
  19.  
  20.    
  21.     local character = player.Character
  22.     if not character then return end
  23.     local h = character:WaitForChild("Humanoid")
  24.        
  25.     h.BodyDepthScale.Value = scale
  26.     h.BodyHeightScale.Value = scale
  27.     h.BodyWidthScale.Value = scale
  28.     h.HeadScale.Value = scale
  29. end
  30.  
  31. local function onPlayerAdded(player)
  32.    
  33.     local stats = Instance.new("Folder")
  34.     stats.Name = "leaderstats"
  35.     stats.Parent = player
  36.    
  37.     player.CharacterAdded:Connect(function()
  38.         UpdatePlayerSize(player)
  39.     end)
  40.    
  41.     local cash = Instance.new("IntValue")
  42.     cash.Name = "Cash"
  43.     cash.Value = 0
  44.     cash.Parent = stats
  45.    
  46.     local storage = Instance.new("IntValue")
  47.     storage.Name = "Storage"
  48.     storage.Value = 5
  49.     storage.Parent = player
  50.    
  51.     local strength = Instance.new("IntValue")
  52.     strength.Name = "Strength"
  53.     strength.Value = 0
  54.     strength.Parent = stats
  55.    
  56.     strength:GetPropertyChangedSignal("Value"):Connect(function()
  57.         UpdatePlayerSize(player)
  58.     end)
  59.    
  60. end
  61.  
  62. players.PlayerAdded:Connect(onPlayerAdded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement