KrYn0MoRe

platform minigame

Jan 6th, 2022 (edited)
947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.76 KB | None | 0 0
  1. local blockfolder = Instance.new("Folder",script)
  2. blockfolder.Name = "blockfolder"
  3. local heighthint = Instance.new("Hint",script)
  4.  
  5. debris = game:GetService("Debris")
  6. tween = game:GetService("TweenService")
  7.  
  8. local oldpos = Vector3.new(0,-2,10)
  9. local lasthit = Vector3.new(0,0,0)
  10. local untouched = 0
  11. local touched = {}
  12.  
  13. local function createpos(r1,r2)
  14.     local v1,v2,v3 = 0,0,0
  15.     if math.random(1,2) == 1 then
  16.         v1 = -math.random(r1,r2)
  17.     else
  18.         v1 = math.random(r1,r2)
  19.     end
  20.     if math.random(1,2) == 1 then
  21.         v2 = -math.random(r1,r2)
  22.     else
  23.         v2 = math.random(r1,r2)
  24.     end
  25.     if math.random(1,2) == 1 then
  26.         v3 = -math.random(r1,r2)
  27.     else
  28.         v3 = math.random(r1,r2)
  29.     end
  30.     return v1,v2,v3
  31. end
  32.  
  33. local function Number(num)
  34.     local UseText = ""
  35.     local StoredScore = num
  36.     local Thousand = false
  37.     for i = 1,StoredScore / 1000 do
  38.         Thousand = true
  39.         StoredScore = StoredScore - 1000
  40.         UseText = UseText.." TH"
  41.     end
  42.     if Thousand then
  43.         UseText = UseText..[[
  44. ]]
  45.     end
  46.     local Hundred = false
  47.     for i = 1,StoredScore / 100 do
  48.         Hundred = true
  49.         StoredScore = StoredScore - 100
  50.         UseText = UseText.." H"
  51.     end
  52.     if Hundred then
  53.         UseText = UseText..[[
  54. ]]
  55.     end
  56.     local Ten = false
  57.     for i = 1,StoredScore / 10 do
  58.         Ten = true
  59.         StoredScore = StoredScore - 10
  60.         UseText = UseText.." T"
  61.     end
  62.     if Ten then
  63.         UseText = UseText..[[
  64. ]]
  65.     end
  66.     for i = 1,StoredScore do
  67.         StoredScore = StoredScore - 1
  68.         UseText = UseText.." I"
  69.     end
  70.     UseText = UseText.." "
  71.     return UseText
  72. end
  73.  
  74. function sleep(n)
  75.     task.wait(n or 0)
  76. end
  77.  
  78. function wrap(func)
  79.     coroutine.wrap(func)()
  80. end
  81.  
  82. function restart(amount)
  83.     local rehint = Instance.new("Hint",script)
  84.     rehint.Text = 'restarting game..'
  85.     debris:AddItem(rehint,amount)
  86.     local timer = amount
  87.     heighthint = "" .. Number(timer)
  88.     wrap(function()
  89.         for i = 1,amount do
  90.             sleep(1)
  91.             timer = timer - 1
  92.             heighthint = "" .. Number(timer)
  93.         end
  94.     end)
  95.     sleep(amount)
  96.     if math.random(1,2) == 1 then
  97.         race(1000,false)
  98.     else
  99.         endless(math.pow(100,100),true)
  100.     end
  101. end
  102.  
  103. local function createblock(par,col,can,anc,pos,mode,buff)
  104.     local part,hitbox,hurt
  105.     if mode == 'normal' then
  106.         part = Instance.new("Part",par)
  107.         part.Anchored = anc
  108.         part.CanCollide = can
  109.         part.Position = pos
  110.         part.Material = Enum.Material.Pebble
  111.         part.Color = col
  112.         part.Size = Vector3.new(7,.5,7)
  113.         part.Locked = true
  114.     elseif mode == 'spin1' then
  115.         part = Instance.new("Part",par)
  116.         part.Anchored = anc
  117.         part.CanCollide = can
  118.         part.Position = pos
  119.         part.Material = Enum.Material.Pebble
  120.         part.Color = col
  121.         part.Size = Vector3.new(7,.5,7)
  122.         part.Locked = true
  123.         hitbox = Instance.new("SelectionBox",part)
  124.         hitbox.Adornee = part
  125.         hitbox.LineThickness = .1
  126.         hitbox.SurfaceTransparency = .5
  127.         hitbox.Color3 = Color3.new(0,0,1)
  128.         part.RotVelocity = Vector3.new(0,3,0)
  129.         wrap(function()
  130.             while sleep() do
  131.                 part.CFrame = part.CFrame*CFrame.Angles(0,.1,0)
  132.             end
  133.         end)
  134.     elseif mode == 'spin2' then
  135.         part = Instance.new("Part",par)
  136.         part.Anchored = anc
  137.         part.CanCollide = can
  138.         part.Position = pos
  139.         part.Material = Enum.Material.Pebble
  140.         part.Color = col
  141.         part.Size = Vector3.new(7,.5,7)
  142.         part.Locked = true
  143.         hitbox = Instance.new("SelectionBox",part)
  144.         hitbox.Adornee = part
  145.         hitbox.LineThickness = .1
  146.         hitbox.SurfaceTransparency = .5
  147.         hitbox.Color3 = Color3.new(0,1,1)
  148.         part.RotVelocity = Vector3.new(0,-3,0)
  149.         wrap(function()
  150.             while sleep() do
  151.                 part.CFrame = part.CFrame*CFrame.Angles(0,-.1,0)
  152.             end
  153.         end)
  154.     elseif mode == 'win' then
  155.         part = Instance.new("Part",par)
  156.         part.Anchored = anc
  157.         part.CanCollide = can
  158.         part.Position = pos
  159.         part.Material = Enum.Material.Neon
  160.         part.Size = Vector3.new(7,.5,7)
  161.         part.Locked = true
  162.         wrap(function()
  163.             while true do
  164.                 part.Color = Color3.new(1,0,0)
  165.                 sleep(0.25)
  166.                 part.Color = Color3.new(1,1,0)
  167.                 sleep(0.25)
  168.                 part.Color = Color3.new(1,1,1)
  169.                 sleep(0.25)
  170.                 part.Color = Color3.new(0,1,1)
  171.                 sleep(0.25)
  172.                 part.Color = Color3.new(0,0,1)
  173.                 sleep(0.25)
  174.             end
  175.         end)
  176.     end
  177.     if buff == 'hurt' then
  178.         hurt = Instance.new("Sound",part)
  179.         hurt.SoundId = "rbxassetid://3362346832"
  180.         hurt.Volume = 0.5
  181.         if hitbox and hitbox.Parent then
  182.             hitbox:Destroy()
  183.         end
  184.         hitbox = Instance.new("SelectionBox",part)
  185.         hitbox.Adornee = part
  186.         hitbox.LineThickness = .1
  187.         hitbox.SurfaceTransparency = .5
  188.         hitbox.Color3 = Color3.new(255/255,152/255,220/255)
  189.         part.Touched:Connect(function(obj)
  190.             if obj.Parent.ClassName == "Model" then
  191.                 local hum = obj.Parent:FindFirstChildOfClass("Humanoid")
  192.                 if hum and hum.Parent and not hum:FindFirstChild("platform poison") then
  193.                     local confirm = Instance.new("IntValue",hum)
  194.                     confirm.Name = 'platform poison'
  195.                     debris:AddItem(confirm,.25)
  196.                     hurt:Play()
  197.                     hum.Health = hum.Health - (hum.MaxHealth/50)
  198.                 end
  199.             end
  200.         end)
  201.     end
  202.     untouched = untouched + 1
  203.     return part
  204. end
  205.  
  206. function create_sound(par,id,vol)
  207.     local s = Instance.new("Sound")
  208.     s.SoundId = "rbxassetid://" .. id
  209.     s.Volume = vol or 0.5
  210.     s.Parent = par or script
  211.     return s
  212. end
  213.  
  214. local win_s = create_sound(script,142389573,0.5)
  215.  
  216. function race(height,hardcore)
  217.     local ended = false
  218.     oldpos = Vector3.new(0,-2,10)
  219.     lasthit = Vector3.new(0,0,0)
  220.     local starthint = Instance.new("Hint",script)
  221.     wrap(function()
  222.         starthint.Text = 'Mode: Race (get to the end and finish the race!)'
  223.         sleep(5)
  224.         win_s:Stop()
  225.         create_sound(script,178029826,0.5):Play()
  226.         starthint.Text = 'starting in III'
  227.         sleep(1)
  228.         starthint.Text = 'starting in II'
  229.         sleep(1)
  230.         starthint.Text = 'starting in I'
  231.         sleep(1)
  232.         starthint.Text = 'GO!'
  233.     end)
  234.     debris:AddItem(starthint,9)
  235.     sleep(9)
  236.     wrap(function()
  237.         while not ended do
  238.             sleep(1)
  239.             if ended then return end
  240.             if height > oldpos.Y then
  241.                 heighthint.Text = [[
  242.  
  243.  
  244.  
  245.  
  246.         Height:
  247.         ]] .. tostring(Number(oldpos.Y))
  248.                 --print(oldpos.Y)
  249.             end
  250.         end
  251.     end)
  252.     while height > oldpos.Y do
  253.         repeat sleep() until 8 > untouched  
  254.         sleep(0.5)
  255.         local v1,v2,v3 = createpos(7,8)
  256.         local pos = oldpos + Vector3.new(v1,8,v2)
  257.         oldpos = pos
  258.         local block
  259.         if hardcore then
  260.             if math.random(1,5) == 3 then
  261.                 if math.random(1,5) == 2 then
  262.                     block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'spin1','hurt')
  263.                 else
  264.                     block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'spin1','default')
  265.                 end
  266.             elseif math.random(1,5) == 2 then
  267.                 if math.random(1,5) == 2 then
  268.                     block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'spin2','hurt')
  269.                 else
  270.                     block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'spin2','default')
  271.                 end
  272.             else
  273.                 if math.random(1,5) == 2 then
  274.                     block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'normal','hurt')
  275.                 else
  276.                     block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'normal','default')
  277.                 end
  278.             end
  279.         else
  280.             block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'normal','default')
  281.         end
  282.        
  283.         create_sound(block,225320558,0.5):Play()
  284.  
  285.         local touched = false
  286.  
  287.         block.Touched:Connect(function(obj)
  288.             if not touched then
  289.                 local hum = obj.Parent:FindFirstChildOfClass("Humanoid")
  290.                 local Above = false
  291.                 local blocks = blockfolder:GetChildren()
  292.                 for i = 1,#blocks do
  293.                     if blocks[i]:IsA("BasePart") and blocks[i].Material ~= Enum.Material.SmoothPlastic and blocks[i].Material ~= Enum.Material.Neon and blocks[i].Position.Y < block.Position.Y then
  294.                         Above = true
  295.                     end
  296.                 end
  297.                 if not Above and block.Material ~= Enum.Material.SmoothPlastic and block.Material ~= Enum.Material.Neon and obj and obj.Parent and hum and hum.Parent and obj.Parent.ClassName == "Model" then
  298.                     touched = true
  299.                     untouched = untouched - 1
  300.                     lasthit = block.Position
  301.                     block.Material = Enum.Material.SmoothPlastic
  302.                     block.Color = Color3.new(0,1,0)
  303.                 elseif Above and obj and obj.Parent and obj.Parent.ClassName == "Model" then
  304.                     obj.Parent:TranslateBy(Vector3.new(0,-360,0))
  305.                     obj.Parent:BreakJoints()
  306.                 end
  307.             end
  308.         end)
  309.     end
  310.  
  311.     repeat sleep() until 8 > untouched  
  312.     sleep(0.5)
  313.     local v1,v2,v3 = createpos(7,8)
  314.     local pos = oldpos + Vector3.new(v1,8,v2)
  315.     oldpos = pos
  316.     local block = createblock(blockfolder,nil,true,true,pos,'win')
  317.    
  318.     create_sound(block,225320558,0.5):Play()
  319.  
  320.     local touched = false
  321.  
  322.     block.Touched:Connect(function(obj)
  323.         if not touched then
  324.             local hum = obj.Parent:FindFirstChildOfClass("Humanoid")
  325.             local Above = false
  326.             local blocks = blockfolder:GetChildren()
  327.             for i = 1,#blocks do
  328.                 if blocks[i]:IsA("BasePart") and blocks[i].Material ~= Enum.Material.SmoothPlastic and blocks[i].Material ~= Enum.Material.Neon and blocks[i].Position.Y < block.Position.Y then
  329.                     Above = true
  330.                 end
  331.             end
  332.             if not Above and obj and obj.Parent and obj.Parent.ClassName == "Model" then
  333.                 touched = true
  334.                 untouched = untouched - 1
  335.                 lasthit = block.Position
  336.                 win_s:Play()
  337.                 wrap(function()
  338.                     for i,v in pairs(blockfolder:GetChildren()) do
  339.                         sleep(.075)
  340.                         v.Anchored = false
  341.                         debris:AddItem(v,10)
  342.                     end
  343.                 end)
  344.                 wrap(function()
  345.                     local winhint = Instance.new("Hint",script)
  346.                     winhint.Text = obj.Parent.Name .. ' Has won!'
  347.                     debris:AddItem(winhint,10)
  348.                     sleep(10)
  349.                     ended = true
  350.                     heighthint.Text = " "
  351.                     oldpos = Vector3.new(0,-2,10)
  352.                     lasthit = Vector3.new(0,0,0)
  353.                     restart(10)
  354.                 end)
  355.             elseif Above and obj and obj.Parent and obj.Parent.ClassName == "Model" then
  356.                 obj.Parent:TranslateBy(Vector3.new(0,-360,0))
  357.                 obj.Parent:BreakJoints()
  358.             end
  359.         end
  360.     end)
  361. end
  362.  
  363. function endless(hardcore)
  364.     local height = 1/0
  365.     local ended = false
  366.     oldpos = Vector3.new(0,-2,10)
  367.     lasthit = Vector3.new(0,0,0)
  368.     local starthint = Instance.new("Hint",script)
  369.     wrap(function()
  370.         starthint.Text = 'Mode: Endless (do your best i guess lol)'
  371.         sleep(5)
  372.         win_s:Stop()
  373.         create_sound(script,178029826,0.5):Play()
  374.         starthint.Text = 'starting in III'
  375.         sleep(1)
  376.         starthint.Text = 'starting in II'
  377.         sleep(1)
  378.         starthint.Text = 'starting in I'
  379.         sleep(1)
  380.         starthint.Text = 'GO!'
  381.     end)
  382.     debris:AddItem(starthint,9)
  383.     sleep(9)
  384.     wrap(function()
  385.         while not ended do
  386.             sleep(1)
  387.             if ended then return end
  388.             if height > oldpos.Y then
  389.                 heighthint.Text = [[
  390.  
  391.  
  392.  
  393.  
  394.         Height:
  395.         ]] .. tostring(Number(oldpos.Y))
  396.                 --print(oldpos.Y)
  397.             end
  398.         end
  399.     end)
  400.     while height > oldpos.Y do
  401.         repeat sleep() until 8 > untouched  
  402.         sleep(0.5)
  403.         local v1,v2,v3 = createpos(7,8)
  404.         local pos = oldpos + Vector3.new(v1,8,v2)
  405.         oldpos = pos
  406.         local block
  407.         if hardcore and oldpos.Y >= 1000 then
  408.             if math.random(1,3) == 3 then
  409.                 if math.random(1,5) == 2 then
  410.                     block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'spin1','hurt')
  411.                 else
  412.                     block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'spin1','default')
  413.                 end
  414.             elseif math.random(1,3) == 2 then
  415.                 if math.random(1,5) == 2 then
  416.                     block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'spin2','hurt')
  417.                 else
  418.                     block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'spin2','default')
  419.                 end
  420.             else
  421.                 if math.random(1,5) == 2 then
  422.                     block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'normal','hurt')
  423.                 else
  424.                     block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'normal','default')
  425.                 end
  426.             end
  427.         elseif hardcore and oldpos.Y >= 3000 then
  428.             if math.random(1,2) == 1 then
  429.                 block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'spin1','hurt')
  430.             else
  431.                 block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'spin2','hurt')
  432.             end
  433.         else
  434.             block = createblock(blockfolder,Color3.new(1,1,1),true,true,pos,'normal','default')
  435.         end
  436.        
  437.         create_sound(block,225320558,0.5):Play()
  438.  
  439.         local touched = false
  440.  
  441.         block.Touched:Connect(function(obj)
  442.             if not touched then
  443.                 local hum = obj.Parent:FindFirstChildOfClass("Humanoid")
  444.                 local Above = false
  445.                 local blocks = blockfolder:GetChildren()
  446.                 for i = 1,#blocks do
  447.                     if blocks[i]:IsA("BasePart") and blocks[i].Material ~= Enum.Material.SmoothPlastic and blocks[i].Material ~= Enum.Material.Neon and blocks[i].Position.Y < block.Position.Y then
  448.                         Above = true
  449.                     end
  450.                 end
  451.                 if not Above and block.Material ~= Enum.Material.SmoothPlastic and block.Material ~= Enum.Material.Neon and obj and obj.Parent and hum and hum.Parent and obj.Parent.ClassName == "Model" then
  452.                     touched = true
  453.                     untouched = untouched - 1
  454.                     lasthit = block.Position
  455.                     block.Material = Enum.Material.SmoothPlastic
  456.                     block.Color = Color3.new(0,1,0)
  457.                     wrap(function()
  458.                         sleep(10)
  459.                         block.Anchored = false
  460.                         debris:AddItem(block,10)
  461.                     end)
  462.                     wrap(function()
  463.                         local oldtouch = lasthit.Y
  464.                         sleep(10)
  465.                         if oldtouch == lasthit.Y then
  466.                             local warninghint = Instance.new("Hint",script)
  467.                             warninghint.Text = "Keep going this can't be the end!"
  468.                             debris:AddItem(warninghint,5)
  469.                         end
  470.                         sleep(5)
  471.                         if oldtouch == lasthit.Y then
  472.                             local warninghint = Instance.new("Hint",script)
  473.                             debris:AddItem(warninghint,5)
  474.                             warninghint.Text = "Game Ended!"
  475.                             ended = true
  476.                             heighthint.Text = " "
  477.                             oldpos = Vector3.new(0,-2,10)
  478.                             lasthit = Vector3.new(0,0,0)
  479.                             wrap(function()
  480.                                 for i,v in pairs(blockfolder:GetChildren()) do
  481.                                     sleep(.025)
  482.                                     v.Anchored = false
  483.                                     debris:AddItem(v,10)
  484.                                 end
  485.                             end)
  486.                             restart(10)
  487.                         end
  488.                     end)
  489.                 elseif Above and obj and obj.Parent and obj.Parent.ClassName == "Model" then
  490.                     obj.Parent:TranslateBy(Vector3.new(0,-360,0))
  491.                     obj.Parent:BreakJoints()
  492.                 end
  493.             end
  494.         end)
  495.     end
  496. end
  497.  
  498. local mode = 0
  499. local hardcore = true
  500.  
  501. if mode == 0 then
  502.     race(1000,hardcore)
  503. elseif mode == 1 then
  504.     endless(math.pow(100,100),hardcore)
  505. end
Add Comment
Please, Sign In to add comment