Advertisement
HowToRoblox

LiftingGameServer

Jun 30th, 2022
3,456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. local dss = game:GetService("DataStoreService")
  2. local ds = dss:GetDataStore("LIFTING SIMULATOR")
  3.  
  4. --Save data
  5. function saveData(player)
  6.     local weight = player.leaderstats.Weight.Value
  7.     ds:SetAsync(player.UserId .. "Weight", weight)
  8. end
  9.  
  10. game.Players.PlayerRemoving:Connect(saveData)
  11. game:BindToClose(function()
  12.     for i, player in pairs(game.Players:GetPlayers()) do
  13.         saveData(player)
  14.     end
  15. end)
  16.  
  17. --Create leaderstats
  18. game.Players.PlayerAdded:Connect(function(player)
  19.    
  20.     local leaderstats = Instance.new("Folder")
  21.     leaderstats.Name = "leaderstats"
  22.     leaderstats.Parent = player
  23.    
  24.     local weight = Instance.new("IntValue")
  25.     weight.Name = "Weight"
  26.     weight.Parent = leaderstats
  27.    
  28.     local data = ds:GetAsync(player.UserId .. "Weight") or 0
  29.    
  30.     weight.Value = data
  31.    
  32.    
  33.     local function scaleBody()
  34.         if not player.Character then player.CharacterAdded:Wait() end
  35.         player.Character.Humanoid.HeadScale.Value = 1 + (weight.Value/20)
  36.         player.Character.Humanoid.BodyDepthScale.Value = 1 + (weight.Value/20)
  37.         player.Character.Humanoid.BodyWidthScale.Value = 1 + (weight.Value/20)
  38.         player.Character.Humanoid.BodyHeightScale.Value = 1 + (weight.Value/20)
  39.        
  40.         local tool = player.Character:FindFirstChildOfClass("Tool") or player.Backpack:FindFirstChildOfClass("Tool")
  41.        
  42.         if tool then
  43.             tool.Handle.Mesh.Scale = Vector3.new(
  44.                 game.StarterPack.Weight.Handle.Mesh.Scale.X + (weight.Value/20 * game.StarterPack.Weight.Handle.Mesh.Scale.X),
  45.                 game.StarterPack.Weight.Handle.Mesh.Scale.Y + (weight.Value/20 * game.StarterPack.Weight.Handle.Mesh.Scale.Y),
  46.                 game.StarterPack.Weight.Handle.Mesh.Scale.Z + (weight.Value/20 * game.StarterPack.Weight.Handle.Mesh.Scale.Z)
  47.             )
  48.         end
  49.     end
  50.    
  51.     scaleBody()
  52.     weight:GetPropertyChangedSignal("Value"):Connect(scaleBody)
  53. end)
  54.  
  55. --Give weight when player lifts
  56. local cooldowns = {}
  57.  
  58. game.ReplicatedStorage.WeightRE.OnServerEvent:Connect(function(player)
  59.     if cooldowns[player] then return end
  60.     cooldowns[player] = true
  61.    
  62.     player.leaderstats.Weight.Value += 1
  63.    
  64.     wait(0.5)
  65.     cooldowns[player] = false
  66. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement