Advertisement
BuildPlayz

Difficulty Chart Obby Scripts

Oct 9th, 2020
8,911
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. --variables
  2. local checkpoints = workspace:WaitForChild("Checkpoints")
  3.  
  4. local DataStoreService = game:GetService("DataStoreService")
  5. local plrStage = DataStoreService:GetDataStore("StageValue")
  6.  
  7.  
  8. local db = true
  9. --when plr joins
  10. game.Players.PlayerAdded:Connect(function(plr)
  11.    
  12.     local leaderstats = Instance.new("Folder")
  13.     leaderstats.Name = "leaderstats"
  14.     leaderstats.Parent = plr
  15.    
  16.     local v = Instance.new("IntValue")
  17.     v.Value = plrStage:GetAsync(plr.UserId,v.Value) or 1
  18.     v.Name = "Stage" --name of currency
  19.     v.Parent = leaderstats
  20.    
  21.     print("Player Data Successfully Loaded!")
  22.    
  23.     v.Changed:Connect(function(value)
  24.         plrStage:SetAsync(plr.UserId,value)
  25.         print("Player Data Successfully Saved!")
  26.     end)
  27.    
  28.     plr.CharacterAdded:Connect(function(char)
  29.         local hum = char:WaitForChild("Humanoid")
  30.         wait(0.1)
  31.        
  32.         wait(char:MoveTo(checkpoints[v.Value].Position))
  33.        
  34.         hum.Touched:Connect(function(hit)
  35.            
  36.             if hit.Parent == checkpoints and char.Humanoid.Health ~= 0 then
  37.                 if tonumber(hit.Name) == v.Value +1 then
  38.                     v.Value = v.Value +1
  39.                 end
  40.                
  41.             elseif hit.Parent == workspace.Damagers then
  42.                 char.Humanoid.Health = char.Humanoid.Health - 4
  43.                 db = false
  44.                 wait(.1)
  45.                 db = true
  46.                
  47.             elseif hit.Parent == workspace.Killers then
  48.                 char.Humanoid.Health = 0
  49.             end
  50.         end)
  51.     end)
  52.    
  53. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement