Advertisement
EmeraldIT

Untitled

Apr 6th, 2023 (edited)
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 46.44 KB | None | 0 0
  1. version = "0.2"
  2.  
  3. -------------------------------------------------Clean up of old scripts + credit
  4.  
  5. for _,v in pairs(game.Players:GetDescendants()) do
  6.     if v.Name == "RacingUI" then
  7.         v:Remove()
  8.     end
  9. end
  10. if game.ReplicatedStorage:FindFirstChild("MasterSound") then
  11.     game.ReplicatedStorage:WaitForChild("MasterSound"):Remove()
  12. end
  13. if workspace:FindFirstChild("The Race") then
  14.     workspace["The Race"]:Remove()
  15. end
  16. script.Name = "The Race"
  17.  
  18. print("This script was made by Rese#2110 - based off of a script made by DevSersponge a long time ago.\nMost recent version: "..version)
  19.  
  20. -------------------------------------------------Value/Key variable assignment and initiation
  21.  
  22. local TweenService = game:GetService("TweenService")
  23.  
  24. local pla = owner
  25. local wo = workspace
  26. local las = nil
  27. local theme = "normal"
  28. local themes = {}
  29. local difficulty = 10 --1, 10
  30. local tilt = "off"
  31. local spawnInterval = 0
  32. local specInterval = 0
  33. local participants = {}
  34. local soundID = "7568675939"
  35. local raceline = nil
  36. local READYSETGO = "READY"
  37. local prefix = "!"
  38. local connectedLine = nil
  39. local new = {}
  40. local movingEnemies = {}
  41. local colorChanging = {}
  42. local ShiftingColor = Color3.new(1, 1, 1)
  43.  
  44. local obstacleFol = Instance.new("Folder", script)
  45. local enemyFol = Instance.new("Folder", script)
  46. local FOL = Instance.new("Folder", script)
  47.  
  48.  
  49. local PLR = pla
  50. local CHA = PLR.Character
  51. local CF = CFrame.new
  52. local ANG = CFrame.Angles
  53. local RAN = math.random
  54. local C3 = Color3.new
  55. local RGB = Color3.fromRGB
  56. local VT = Vector3.new
  57. local UD = UDim2.new
  58. local SEQ = NumberSequence.new
  59. local CSEQ = ColorSequence.new
  60. local NKEY = NumberSequenceKeypoint.new
  61. local RANGE = NumberRange.new
  62.  
  63. -------------------------------------------------------------UI, sound and NLS stuff
  64.  
  65. local ui = Instance.new("ScreenGui")
  66. local Mastersound = game.ReplicatedStorage:FindFirstChild("MasterSound") or Instance.new("Sound")
  67. local distance = Instance.new("TextLabel")
  68. local points = Instance.new("TextLabel")
  69. local place = Instance.new("TextLabel")
  70. local screenEffect = Instance.new("Frame")
  71. local modeindicator = Instance.new("TextLabel")
  72. local diffindicator = Instance.new("TextLabel")
  73. local songindicator = Instance.new("TextLabel")
  74. local notif = Instance.new("TextLabel")
  75. local countdown = Instance.new("TextLabel")
  76. local Repped = (function() if Mastersound.Name == "MasterSound" then return Mastersound.SoundEvent else return Instance.new("RemoteEvent") end end)()
  77. Repped.Name = "SoundEvent"
  78. screenEffect.Name = "ScreenEffect"
  79. screenEffect.AnchorPoint = Vector2.new(.5, .5)
  80. screenEffect.Size = UDim2.new(1, 5, 1, 5)
  81. screenEffect.BackgroundTransparency = 1
  82. distance.Text = "Distance till end: "
  83. distance.Name = "Distance"
  84. points.Text = "Points: "
  85. points.Name = "Points"
  86. place.Text = "Rank: "
  87. place.Name = "Place"
  88. modeindicator.Text = "Race track: "
  89. modeindicator.Name = "ModeIndicator"
  90. diffindicator.Text = "Difficulty: "
  91. diffindicator.Name = "DiffIndicator"
  92. songindicator.Text = "Music playing: "
  93. songindicator.Name = "SongIndicator"
  94. notif.Text = ""
  95. notif.Name = "Notification"
  96. countdown.Text = "- STOP -"
  97. countdown.Name = "Countdown"
  98. Mastersound.Name = "MasterSound"
  99. Mastersound.SoundId = "rbxassetid://"..soundID
  100. Mastersound.Playing = false
  101. Mastersound.Volume = 1
  102. Mastersound.Looped = true
  103. Mastersound.Parent = game.ReplicatedStorage
  104. Repped.Parent = Mastersound
  105. local sound = Mastersound:Clone()
  106. sound.Parent = ui
  107. sound.Playing = false
  108. sound.Name = "RepSound"
  109. ui.Name = "RacingUI"
  110.  
  111. local labelsframe = Instance.new("Frame")
  112. labelsframe.Size = UDim2.new(.15, 0, .4, 0)
  113. labelsframe.BackgroundTransparency = 1
  114. labelsframe.AnchorPoint = Vector2.new(0, 0.5)
  115. labelsframe.Position = UDim2.new(0, 0, 0.5, 0)
  116.  
  117. local bevel = Instance.new("UIStroke")
  118. bevel.ApplyStrokeMode = "Border"
  119. bevel.LineJoinMode = "Bevel"
  120. bevel.Thickness = 4
  121. bevel.Color = Color3.new(0.3, 0.3, 0.3)
  122. local corner = Instance.new("UICorner")
  123.  
  124. distance.Parent = labelsframe
  125. points.Parent = labelsframe
  126. place.Parent = labelsframe
  127. modeindicator.Parent = labelsframe
  128. diffindicator.Parent = labelsframe
  129. songindicator.Parent = labelsframe
  130.  
  131. local maxTextSize = Instance.new("UITextSizeConstraint")
  132. maxTextSize.MaxTextSize = 35
  133.  
  134. countdown.Size = UDim2.new(0.3, 0, 0.1, 0)
  135. countdown.AnchorPoint = Vector2.new(0.5, 0.5)
  136. countdown.Position = UDim2.new(0.5, 0, -1, 0)
  137. countdown.TextColor3 = Color3.new(1, 0, 0)
  138. countdown.Parent = ui
  139. countdown.Name = "Countdown"
  140.  
  141. labelsframe.Parent = ui
  142.  
  143. local yes = 0
  144.  
  145. for _,v in pairs(ui:GetDescendants()) do
  146.     if v:IsA("TextLabel") then
  147.         v.TextScaled = true
  148.         v.TextStrokeColor3 = Color3.new(0, 0, 0)
  149.         v.TextStrokeTransparency = 0   
  150.         v.BackgroundTransparency = 1
  151.         v.AnchorPoint = Vector2.new(.5, .5)
  152.         v.RichText = true
  153.         v.Font = "SciFi"
  154.         maxTextSize:Clone().Parent = v
  155.         if v == countdown then
  156.             v.Font = "Arcade"
  157.         end
  158.         if v.Parent == labelsframe then
  159.             v.Size = UDim2.new(1, 0, 0.15, 0)
  160.             bevel:Clone().Parent = v
  161.             corner:Clone().Parent = v
  162.             v.BackgroundTransparency = 0.9
  163.             v.TextColor3 = Color3.new(1, 1, 1)
  164.             v.BackgroundColor3 = Color3.new(1, 1, 1)
  165.             v.TextXAlignment = "Left"
  166.             v.Position = UDim2.new(-1, 0, 0.15*yes, 10)
  167.             yes = yes + 1
  168.         end
  169.     end
  170. end
  171.  
  172. UiNLS = [[
  173. local ui = script.Parent
  174. local Mastersound = game.ReplicatedStorage:WaitForChild("MasterSound")
  175. local MarketPlaceService = game:GetService("MarketplaceService")
  176. local labelsframe = ui.Frame
  177. local distance = labelsframe.Distance
  178. local points = labelsframe.Points
  179. local place = labelsframe.Place
  180. local modeindicator = labelsframe.ModeIndicator
  181. local diffindicator = labelsframe.DiffIndicator
  182. local songindicator = labelsframe.SongIndicator
  183. local countdown = ui.Countdown
  184. local sound = ui.RepSound
  185. local repped = Mastersound:WaitForChild("SoundEvent")
  186. local TweenService = game:GetService("TweenService")
  187. local tween = function(part, info, tweeninfo)
  188. local yes = 0
  189. local tweenInfo = TweenInfo.new(
  190.     tweeninfo.Time, -- Time
  191.     tweeninfo.Style, -- EasingStyle
  192.     tweeninfo.Direction, -- EasingDirection
  193.     tweeninfo.Repeat, -- RepeatCount (when less than zero the tween will loop indefinitely)
  194.     tweeninfo.Reverses, -- Reverses (tween will reverse once reaching it's goal)
  195.     tweeninfo.Delay -- DelayTime
  196. )
  197. local tween = TweenService:Create(part, tweenInfo, info)
  198. tween:Play()
  199. return tween
  200. end
  201.  
  202. local mode = "ready"
  203.  
  204. function refreshUi()
  205.     yes = 0
  206.     for i,v in pairs(ui.Frame:GetChildren()) do
  207.         if v:IsA("TextLabel") then
  208.             v.Position = UDim2.new(-1, 0, 0.15*yes, 2)
  209.             yes = yes + 1
  210.         end
  211.     end
  212.     yes = 0
  213.     ui.Countdown.Position = UDim2.new(0.5, 0, -1, 0)
  214.     tween(ui.Countdown, {Position = UDim2.new(0.5, 0, 0.5, 0)}, {Time = 2, Style = Enum.EasingStyle.Bounce, Direction = Enum.EasingDirection.Out, Repeat = 0, Reverses = false, Delay = 0})
  215.     for i,v in pairs(ui.Frame:GetChildren()) do
  216.         if v:IsA("TextLabel") then
  217.             tween(v, {Position = UDim2.new(0.6, 0, 0.15*yes, 2)}, {Time = 2, Style = Enum.EasingStyle.Back, Direction = Enum.EasingDirection.Out, Repeat = 0, Reverses = false, Delay = 0})
  218.             yes = yes + 1
  219.             wait(0.2)
  220.         end
  221.     end
  222. end
  223.  
  224. function checkSou(detail)
  225.     if detail == "Play" then
  226.         detail = true
  227.         sound.TimePosition = 0
  228.     elseif detail == "Keep Playing" then
  229.         detail = true
  230.     elseif detail == "Stop Playing" then
  231.         detail = false
  232.     elseif detail == "Change Id" then
  233.         sound.SoundId = Mastersound.SoundId
  234.         detail = sound.Playing
  235.     end
  236.     local success, asset = pcall(MarketPlaceService.GetProductInfo,MarketPlaceService, string.sub(Mastersound.SoundId, string.len("rbxassetid://")+1))
  237.     songindicator.Text = "Music playing: "..(asset.Name or "None").." - "..string.sub(Mastersound.SoundId, string.len("rbxassetid://")+1)
  238.     sound.Volume = Mastersound.Volume
  239.     sound.Playing = detail
  240. end
  241.  
  242. local makeSou = function(parent, id, vol, play, playOnRemove)
  243.     local Sound = Instance.new("Sound")
  244.     Sound.Volume = vol
  245.     Sound.SoundId = id
  246.     if playOnRemove then
  247.         Sound.PlayOnRemove = true
  248.     end
  249.     Sound.Parent = parent or workspace
  250.     if play then
  251.         Sound:Play()
  252.     end
  253.     return Sound
  254. end
  255.  
  256. owner.Character.Destroying:Connect(function()
  257.     ui:Remove()
  258.     script.Disabled = true
  259. end)
  260.  
  261. owner.Character:FindFirstChildOfClass("Humanoid").Died:Connect(function()
  262.     ui:Remove()
  263.     script.Disabled = true
  264. end)
  265.  
  266. local playing = false
  267.  
  268. local Testingtick = tick()
  269.  
  270. repped.OnClientEvent:Connect(function(typeOfUpdate, details)
  271.     if typeOfUpdate == "points" then
  272.         points.Text = "Points: "..details.Points
  273.     elseif typeOfUpdate == "place" then
  274.         local newT = {}
  275.         local num = 0
  276.         for i, v in pairs(details) do
  277.             num = num + 1
  278.             local pos = v[1]
  279.             newT[pos] = num
  280.         end
  281.         YourRank = newT[owner.Name]
  282.         if YourRank == 1 then
  283.             place.Text = 'Rank: <b><font face="Arcade"><font color="#FFD966"><stroke color="#FFDF99" joins="miter" thickness="2" transparency="0.5">1ST PLACE!</stroke></font></font></b>'
  284.         elseif YourRank == 2 then
  285.             place.Text = 'Rank: <b><font face="Garamond"><font color="#CCCCFF"><stroke color="#FFFFFF" joins="miter" thickness="2" transparency="0.5">2nd Place!</stroke></font></font></b>'
  286.         elseif YourRank == 3 then
  287.             place.Text = 'Rank: <b><font face="Bodoni"><font color="#773300"><stroke color="#FF9900" joins="miter" thickness="2" transparency="0.5">3rd Place!</stroke></font></font></b>'
  288.         else
  289.             place.Text = "Rank: <b>"..YourRank.."th".."</b>"
  290.         end
  291.     elseif typeOfUpdate == "distance" then
  292.         distance.Text = "Distance till end: "..details.Distance.." meters"
  293.     elseif typeOfUpdate == "maptype" then
  294.         refreshUi()
  295.         checkSou(false)
  296.         diffindicator.Text = "Difficulty: <b><font face = 'Arcade'>"..(function()
  297. if details.Difficulty then
  298.     if details.Difficulty == "Very Hard" then
  299.         return '<font color="#FF0000"><stroke color="#000000" joins="miter" thickness="2" transparency="0.5">Very Hard</stroke></font></font>'
  300.     elseif details.Difficulty == "Hard" then
  301.         return '<font color="#FF2200"><stroke color="#000000" joins="miter" thickness="2" transparency="0.5">Hard</stroke></font></font>'
  302.     elseif details.Difficulty == "Moderate" then
  303.         return '<font color="#FFAA00"><stroke color="#000000" joins="miter" thickness="2" transparency="0.5">Moderate</stroke></font></font>'
  304.     elseif details.Difficulty == "Normal" then
  305.         return '<font color="#FFCC00"><stroke color="#000000" joins="miter" thickness="2" transparency="0.5">Normal</stroke></font></font>'
  306.     elseif details.Difficulty == "Easy" then
  307.         return '<font color="#CCFF00"><stroke color="#000000" joins="miter" thickness="2" transparency="0.5">Easy</stroke></font></font>'
  308.     end
  309. else
  310.     return '<font color="#CC8899"><stroke color="#FFFFFF" joins="miter" thickness="2" transparency="0.5">???</stroke></font></font>'
  311. end
  312. end)().."</b>"
  313.         modeindicator.Text = "Race track: <b>"..details.Custom..details.Track..details.CustomEnd.."</b>"
  314.     elseif typeOfUpdate == "music" then
  315.         detail = details.CMD
  316.         checkSou(detail)
  317.     elseif typeOfUpdate == "readyset" then 
  318.         makeSou(ui, "rbxassetid://5448028218", 0.5, true)
  319.         mode = typeOfUpdate
  320.         countdown.Text = details.Text
  321.         tween(countdown, {TextColor3 = details.Color}, {Time = 0.4, Style = Enum.EasingStyle.Cubic, Direction = Enum.EasingDirection.InOut, Repeat = 0, Reverses = false, Delay = 0})
  322.     elseif typeOfUpdate == "go" then
  323.         makeSou(ui, "rbxassetid://538405084", 0.5, true)
  324.         playing = false
  325.         mode = typeOfUpdate
  326.         countdown.Text = "! GO !"
  327.         tween(countdown, {TextColor3 = Color3.new(0, 1, 0.5)}, {Time = 0.25, Style = Enum.EasingStyle.Cubic, Direction = Enum.EasingDirection.InOut, Repeat = 0, Reverses = false, Delay = 0})
  328.         wait(0.25)
  329.         tween(countdown, {Position = UDim2.new(0.5, 0, -1, 0)}, {Time = 2, Style = Enum.EasingStyle.Elastic, Direction = Enum.EasingDirection.Out, Repeat = 0, Reverses = false, Delay = 0})
  330.     elseif typeOfUpdate == "SFX" then
  331.         makeSou(ui, "rbxassetid://"..details.ID, details.Loudness or 0.5, true)
  332.     end
  333. end)
  334.  
  335. game:GetService("RunService").RenderStepped:Connect(function()
  336.     if mode == "go" and owner.Character and owner.Character:FindFirstChild("Participating") then
  337.         owner.Character.Humanoid.WalkSpeed = 1000
  338.     end
  339.     if not owner.Character:FindFirstChild("Participating") then
  340.         ui:Remove()
  341.         script.Disabled = true
  342.     end
  343. end)
  344. ]]
  345.  
  346. ---------------------------------------------------------------Useful functions
  347.  
  348. local tween = function(part, info, tweeninfo)
  349.     local tweenInfo = TweenInfo.new(
  350.         tweeninfo.Time, -- Time
  351.         tweeninfo.Style, -- EasingStyle
  352.         tweeninfo.Direction, -- EasingDirection
  353.         tweeninfo.Repeat, -- RepeatCount (when less than zero the tween will loop indefinitely)
  354.         tweeninfo.Reverses, -- Reverses (tween will reverse once reaching it's goal)
  355.         tweeninfo.Delay -- DelayTime
  356.     )
  357.  
  358.     local tween = TweenService:Create(part, tweenInfo, info)
  359.     tween:Play()
  360.     return tween
  361. end
  362.  
  363. local makeSou = function(parent, id, vol, play, playOnRemove)
  364.     local Sound = Instance.new("Sound")
  365.     Sound.Volume = vol
  366.     Sound.SoundId = id
  367.     if playOnRemove then
  368.         Sound.PlayOnRemove = true
  369.     end
  370.     Sound.Parent = parent or workspace
  371.     if play then
  372.         Sound:Play()
  373.     end
  374.     return Sound
  375. end
  376.  
  377. local indicate = function(part, color, texthere, size)
  378.     local indi = Instance.new("SpawnLocation")
  379.     indi.Neutral = false
  380.     indi.Size = Vector3.new(.01, .01, .01)
  381.     indi.Transparency = 1
  382.     indi.CanCollide = false
  383.     indi.Massless = true
  384.     if not size then
  385.         size = 1
  386.     end
  387.  
  388.     local holdingUI = Instance.new("BillboardGui")
  389.     holdingUI.Parent = indi
  390.     holdingUI.Adornee = indi
  391.     holdingUI.AlwaysOnTop = true
  392.     holdingUI.MaxDistance = 700
  393.     holdingUI.Brightness = 1
  394.     holdingUI.Size = UDim2.new(10*size, 0, 10*size, 0)
  395.     holdingUI.StudsOffset = Vector3.new(5, -5, 0)
  396.     holdingUI.DistanceUpperLimit = 1
  397.     holdingUI.DistanceLowerLimit = 100
  398.  
  399.     local text = Instance.new("TextLabel")
  400.     text.Size = UDim2.new(1, 0, 1, 0)
  401.     text.TextScaled = true
  402.     text.Font = "Arcade"
  403.     text.TextStrokeTransparency = 0
  404.     text.TextStrokeColor3 = Color3.new(0, 0, 0)
  405.     text.TextColor3 = color
  406.     text.BackgroundTransparency = 1
  407.     text.AnchorPoint = Vector2.new(.5, .5)
  408.     text.Text = texthere
  409.     repeat wait() until text.Text == texthere
  410.     text.Parent = holdingUI
  411.  
  412.     local weld = Instance.new("Weld")
  413.     weld.C0 = CFrame.new(0,0,0)
  414.     weld.Part0 = part
  415.     weld.Part1 = indi
  416.     weld.Parent = indi
  417.  
  418.     indi.Parent = part
  419.     return text
  420. end
  421.  
  422. local part = function(parent, doesdelete, duration, size, cframe, position, material, transparency, reflectance, anchored, cancollide, shape)
  423.     local p = Instance.new("SpawnLocation")
  424.  
  425.     --If statements
  426.     if shape and shape == "Sphere" then
  427.         local pm = Instance.new("SpecialMesh")
  428.         pm.MeshType = "Sphere"
  429.         pm.Parent = p
  430.     elseif shape and shape ~= "Sphere" then
  431.         p.Shape = "Block"
  432.     end
  433.     if cframe then
  434.         p.CFrame = cframe
  435.     elseif position then
  436.         p.Position = position
  437.     end
  438.     if doesdelete then
  439.         game.Debris:AddItem(p, duration)
  440.     end
  441.  
  442.     p.Size = size
  443.     p.Material = material or "Neon"
  444.     p.Neutral = false
  445.     p.Transparency = transparency
  446.     p.Reflectance = reflectance
  447.     p.Anchored = anchored or true
  448.     p.CanCollide = cancollide or false
  449.     p.Parent = parent
  450.     return p
  451. end
  452.  
  453. local pte = function(parent, lightemission, lightinfluence, color, transparency, drag, locked, accel, rate, lifetime, rotspeed, rotation, spread, speed, size, texture, z, direction, enabled)
  454.     local pe = Instance.new("ParticleEmitter")
  455.     pe.LightEmission = lightemission
  456.     pe.LightInfluence = lightinfluence
  457.     pe.Color = color
  458.     pe.Size = size
  459.     pe.Transparency = transparency
  460.     pe.ZOffset = z
  461.     pe.EmissionDirection = direction
  462.     pe.Rate = rate
  463.     pe.LockedToPart = locked
  464.     pe.Acceleration = accel or Vector3.new(0,0,0)
  465.     pe.Lifetime = lifetime
  466.     pe.RotSpeed = rotspeed
  467.     pe.Rotation = rotation
  468.     pe.SpreadAngle = spread
  469.     pe.Speed = speed
  470.     pe.Texture = texture
  471.     pe.Enabled = enabled
  472.     pe.Drag = drag
  473.     pe.Parent = parent
  474.     return pe
  475. end
  476.  
  477. local trail = function(parent, temp, period, texture, col, enabled, turning, lighte, lighti, max, min, textlen, textmode, tran, wids, life)
  478.     local tr = Instance.new("Trail")
  479.     local att = Instance.new("Attachment")
  480.     local att2 = Instance.new("Attachment")
  481.     att.Parent = parent
  482.     att2.Parent = parent
  483.     att.Position = VT(0,parent.Size.Y/2,0)
  484.     att2.Position = VT(0,-parent.Size.Y/2,0)
  485.     tr.Enabled = enabled
  486.     tr.Texture = texture
  487.     tr.Color = col
  488.     tr.FaceCamera = turning
  489.     tr.LightEmission = lighte
  490.     tr.LightInfluence = lighti
  491.     tr.MaxLength = max
  492.     tr.Lifetime = life
  493.     tr.MinLength = min
  494.     tr.TextureLength = textlen
  495.     tr.TextureMode = textmode
  496.     tr.Transparency = tran
  497.     tr.WidthScale = wids
  498.     tr.Attachment0 = att
  499.     tr.Attachment1 = att2
  500.     if temp then
  501.         spawn(function()
  502.             wait(period)
  503.             tr.Enabled = false
  504.             wait(life)
  505.             tr:Destroy()
  506.         end)
  507.     end
  508.     tr.Parent = parent
  509.     return tr
  510. end
  511.  
  512. local virtualize = function(instakill, thing)
  513.     if instakill == true then
  514.         thing.Touched:Connect(function(touched)
  515.  
  516.         end)
  517.     elseif instakill == false then
  518.         thing.Touched:Connect(function(touched)
  519.             if touched.Parent and touched.Parent:FindFirstChildOfClass("Humanoid") then
  520.                 if touched.Parent.Parent and touched.Parent.Parent == CHA then return end
  521.                 if touched.Parent:FindFirstChild("STUNNED") then return end
  522.                 hum = touched.Parent:FindFirstChildOfClass("Humanoid")
  523.                 debo = Instance.new("BoolValue")
  524.                 debo.Name = "STUNNED"
  525.                 debo.Parent = touched
  526.                 game.Debris:AddItem(debo, 3)
  527.                 truw = hum.WalkSpeed
  528.                 truj = hum.JumpPower
  529.                 if hum.MaxHealth >= math.huge then
  530.                     spawn(function()
  531.                         while true do
  532.                             hum.MaxHealth = 100
  533.                             wait()
  534.                         end
  535.                     end)
  536.                 end
  537.                 spawn(function()
  538.                     if (not touched:FindFirstChildOfClass("ParticleEmitter")) and (touched.Name == "Head" or touched.Name == "FakeHead" or touched.Name == "HumanoidRootPart" or touched.Name == "Torso") then
  539.                         local pt = pte(touched, 1, 0, CSEQ(RGB(0,255,100)), SEQ({NKEY(0,0), NKEY(1,0)}), 0, true, nil, 20, NumberRange.new(0.1), NumberRange.new(100), NumberRange.new(-180,180), Vector2.new(0), NumberRange.new(0), SEQ({NKEY(0,0),NKEY(0.2,10),NKEY(0.8,10),NKEY(1,0)}), "rbxassetid://516107903", 3, "Top", true)
  540.                         game.Debris:AddItem(pt, 3)
  541.                     end
  542.                     spawn(function()
  543.                         for i = 1,100 do
  544.                             hum.WalkSpeed = math.random(1,10)
  545.                             hum.JumpPower = math.random(1,20)
  546.                             hum.Health = hum.Health - (hum.MaxHealth / 5000)
  547.                             wait()
  548.                         end
  549.                     end)
  550.                     hum.WalkSpeed = truw
  551.                     hum.JumpPower = truj
  552.                 end)
  553.             end
  554.         end)
  555.     end
  556. end
  557.  
  558. local spark = function(origin, time, inc, HARMLESS)
  559.     x = 0
  560.     z = 0
  561.     local p = part(FOL, true, time, VT(1,1,1), nil, origin.Position, "Neon", 1, 0, true, false, nil)
  562.     if not HARMLESS then
  563.         virtualize(false, p)
  564.     end
  565.     local tr = trail(p, true, (time/10)*3, "", CSEQ(RGB(0,255,100)), true, true, 1, 0, math.huge, 0, 1, "Stretch", SEQ({NKEY(0,0),NKEY(1,0)}), SEQ({NKEY(0,1),NKEY(1,0)}), 3)
  566.     spawn(function()
  567.         for i = 1,time do
  568.             ran = RAN(1,4)
  569.             if ran == 1 then
  570.                 x = inc
  571.                 z = 0
  572.             elseif ran == 2 then
  573.                 x = -inc
  574.                 z = 0
  575.             elseif ran == 3 then
  576.                 x = 0
  577.                 z = inc
  578.             elseif ran == 4 then
  579.                 x = 0
  580.                 z = -inc
  581.             end
  582.             p.CFrame = p.CFrame*CF(x,0,z)
  583.             wait()
  584.         end
  585.     end)
  586. end
  587.  
  588. local spark360 = function(origin, time, inc, col, HARMLESS)
  589.     local p = part(FOL, true, time, VT(1,1,1), nil, origin.Position, "Neon", 1, 0, true, false, nil)
  590.     if not HARMLESS then
  591.         virtualize(false, p)
  592.     end
  593.     local tr = trail(p, true, (time/10)*3, "", col, true, true, 1, 0, math.huge, 0, 1, "Stretch", SEQ({NKEY(0,0),NKEY(1,0)}), SEQ({NKEY(0,1),NKEY(1,0)}), 3)
  594.     spawn(function()
  595.         for i = 1,time do
  596.             ran = RAN(1,6)
  597.             if ran == 1 then
  598.                 x = inc
  599.                 y = 0
  600.                 z = 0
  601.             elseif ran == 2 then
  602.                 x = -inc
  603.                 y = 0
  604.                 z = 0
  605.             elseif ran == 3 then
  606.                 x = 0
  607.                 y = 0
  608.                 z = inc
  609.             elseif ran == 4 then
  610.                 x = 0
  611.                 y = 0
  612.                 z = -inc
  613.             elseif ran == 5 then
  614.                 x = 0
  615.                 y = inc
  616.                 z = 0
  617.             elseif ran == 6 then
  618.                 x = 0
  619.                 y = -inc
  620.                 z = 0
  621.             end
  622.             p.CFrame = p.CFrame*CF(x,y,z)
  623.             wait()
  624.         end
  625.     end)
  626. end
  627.  
  628. local swait = function(amount)
  629.     if amount then
  630.         for i = 1, amount do
  631.             game:GetService("RunService").Stepped:Wait()
  632.         end
  633.     else
  634.         game:GetService("RunService").Stepped:Wait()
  635.     end
  636. end
  637.  
  638. -----------------------------------------------------------------------Race-only functions
  639.  
  640. local finishGlitch = function(item, text, col, size)
  641.    
  642.     spawn(function()
  643.         for i = 1, 50 do
  644.             spark360(item.CFrame, 50, size, col, true)
  645.             spark360(item.CFrame, 50, size*1.5, col, true)
  646.         end
  647.     end)
  648. end
  649.  
  650. local finishEffect = function(item, text, col, playergiven)
  651.     hint = Instance.new("Hint")
  652.     hint.Text = text
  653.     hint.Parent = workspace
  654.     game.Debris:AddItem(hint, 5)
  655.     if not col then
  656.         col = CSEQ(RGB(255,220,70), RGB(255,255,100))
  657.     end
  658.     pcall(function()
  659.         if playergiven.Character.Head:FindFirstChild("WinnerEgo") then return end
  660.         local bv = Instance.new("BodyVelocity")
  661.         bv.Velocity = Vector3.new(math.random(-700, 700), math.random(1000, 2000), math.random(-700, 700))
  662.         bv.MaxForce = Vector3.new(1e9, 1e9, 1e9)
  663.         bv.Name = "WinnerEgo"
  664.         bv.Parent = playergiven.Character.Head 
  665.         game.Debris:AddItem(bv, 0.2)
  666.     end)
  667.     spawn(function()
  668.         for i = 1, 100 do  
  669.             local p = Instance.new("SpawnLocation")
  670.             p.Neutral = false
  671.             p.Anchored = false
  672.             p.Size = Vector3.new(10, 10, 10)
  673.             p.Position = item.Position
  674.             p.Transparency = 0
  675.             p.Material = "Neon"
  676.             p.Color = item.Color
  677.             p.Parent = FOL
  678.             game.Debris:AddItem(p, 20)
  679.             local tr = trail(p, false, nil, "", col, true, true, 1, 0, math.huge, 0, 1, "Stretch", SEQ({NKEY(0,0),NKEY(1,0)}), SEQ({NKEY(0,10),NKEY(1,0)}), 1)
  680.             local bv = Instance.new("BodyVelocity")
  681.             bv.Velocity = Vector3.new(math.random(-1000, 1000), math.random(700, 2000), math.random(-1000, 1000))
  682.             bv.MaxForce = Vector3.new(1e9, 1e9, 1e9)
  683.             bv.Name = "WinnerVel"
  684.             bv.Parent = p
  685.             game.Debris:AddItem(bv, 0.2)
  686.         end
  687.     end)
  688. end
  689.  
  690. local enemy = function(enemyType, place, size, special)
  691.     local p = Instance.new("SpawnLocation")
  692.     p.Material = "Neon"
  693.     p.Neutral = false
  694.     p.Massless = true
  695.     p.Anchored = false
  696.     p.CanCollide = false
  697.     p.Position = place + Vector3.new(0, 1000, 0)
  698.     p.Transparency = 0
  699.     p.Size = Vector3.new(size, size, size)
  700.     local pf = p:Clone()
  701.     pf.Material = "ForceField"
  702.     pf.Color = Color3.new(1, 0, 0)
  703.     pf.Name = "EnemyAura"
  704.     pf.Transparency = 0.3
  705.     pf.Size = p.Size + (Vector3.new(0.2, 0.2, 0.2)*size)
  706.     local weld = Instance.new("Weld")
  707.     weld.Part0 = p
  708.     weld.Part1 = pf
  709.     weld.C0 = CFrame.new(0,0,0)
  710.     weld.Parent = pf
  711.     pf.Parent = p  
  712.  
  713.     local bp = Instance.new("BodyPosition")
  714.     bp.Position = place
  715.     bp.Name = "BP"
  716.     bp.Parent = p
  717.     bp.MaxForce = Vector3.new(1e9, 1e9, 1e9)
  718.    
  719.     local originP = Instance.new("Vector3Value")
  720.     originP.Value = place
  721.     originP.Name = "OriginalPlace"
  722.     originP.Parent = p
  723.  
  724.     local spin = Instance.new("BodyAngularVelocity")
  725.     spin.AngularVelocity = Vector3.new(math.random(-10,10)/10, math.random(-10,10)/10, math.random(-10,10)/10)
  726.     spin.MaxTorque = Vector3.new(1e9, 1e9, 1e9)
  727.     spin.Parent = p
  728.     spin.Name = "BV"
  729.  
  730.     if enemyType == "fling ghost" then
  731.         p.Color = Color3.new(0.3, 0, 0)
  732.         if special ~= nil then
  733.             indicate(p, special.Color, special.Text, 1.25)
  734.             pf.Color = special.Color
  735.             p.Color = Color3.new(0, 0, 0)
  736.         else
  737.             indicate(p, Color3.new(1, 0, 0), "!", 1.25)
  738.         end
  739.         local pos = nil
  740.         p.Touched:Connect(function(h)
  741.             if (not h:IsDescendantOf(script)) and (h ~= workspace.Base) and (h ~= pf) then
  742.                 p.Parent = nil
  743.                 pos = p.Position
  744.                 local p2 = Instance.new("SpawnLocation")
  745.                 p2.Material = "Neon"
  746.                 p2.Neutral = false
  747.                 p2.Massless = true
  748.                 p2.Position = pos
  749.                 p2.Anchored = true
  750.                 p2.CanCollide = false
  751.                 p2.Transparency = 0
  752.                 p2.CastShadow = false
  753.                 p2.Size = Vector3.new(size, size, size)*10
  754.                 if special ~= nil then
  755.                     p2.Color = pf.Color
  756.                 else
  757.                     p2.Color = p.Color
  758.                 end
  759.                 p2.Shape = "Ball"
  760.                 spawn(function()
  761.                     for i = 1, 10 do
  762.                         p2.Transparency = i/10
  763.                         swait()
  764.                     end
  765.                     p2:Remove()
  766.                     wait(3)
  767.                     p.Parent = script
  768.                 end)
  769.                 effected = {}
  770.                 for _, player in pairs(participants) do
  771.                         dist = player:DistanceFromCharacter(p2.Position)
  772.                     if dist <= size*10*2 and not effected[player.Name] then
  773.                         effected[player.Name] = true
  774.                         bv = Instance.new("BodyVelocity")
  775.                         bv.Velocity = Vector3.new(math.random(-1000, 1000), math.random(0, 200), math.random(-1000, 1000))
  776.                         bv.MaxForce = Vector3.new(1e9, 1e9, 1e9)
  777.                         pcall(function()
  778.                             bv.Parent = player.Character.Head  
  779.                         end)
  780.                         Repped:FireClient(player, "SFX", {ID = 6817150074, Loudness = 0.5})
  781.                         game.Debris:AddItem(bv, 0.2)
  782.                     end
  783.                 end
  784.                 p2.Parent = script
  785.             end
  786.         end)
  787.     elseif enemyType == "powerup_random" then
  788.         p.Color = Color3.new(1, 1, 1)
  789.         pf.Color = Color3.new(0, 1, 0.5)
  790.         local textthing = indicate(p, Color3.new(0, 1, 0.5), "?", 1.25)
  791.         table.insert(colorChanging, pf)
  792.         table.insert(colorChanging, textthing)
  793.         local pos = nil
  794.         p.Touched:Connect(function(h)
  795.             if (not h:IsDescendantOf(script)) and (h ~= workspace.Base) and (h ~= pf) then
  796.                 p.Parent = nil
  797.                 pos = p.Position
  798.                 local p2 = Instance.new("SpawnLocation")
  799.                 p2.Material = "Neon"
  800.                 p2.Neutral = false
  801.                 p2.Massless = true
  802.                 p2.Position = pos
  803.                 p2.Anchored = true
  804.                 p2.CastShadow = false
  805.                 p2.CanCollide = false
  806.                 p2.Transparency = 0
  807.                 p2.Size = Vector3.new(size, size, size)*10
  808.                 p2.Color = p.Color
  809.                 p2.Shape = "Ball"
  810.                 spawn(function()
  811.                     for i = 1, 10 do
  812.                         p2.Transparency = i/10
  813.                         swait()
  814.                     end
  815.                     p2:Remove()
  816.                     wait(3)
  817.                     p.Parent = script
  818.                 end)
  819.                 p2.Parent = script
  820.             end
  821.         end)
  822.     elseif enemyType == "starfall fling" then
  823.         p.Color = Color3.new(1, .7, 0.7)
  824.         p.Anchored = true
  825.         bp:Remove()
  826.         attach = Instance.new("Attachment")
  827.         attach.Position = Vector3.new(0,p.Size.Y/2,0)
  828.         attach.Parent = p
  829.         attach2 = Instance.new("Attachment")
  830.         attach2.Position = Vector3.new(0,-p.Size.Y/2,0)
  831.         attach2.Parent = p
  832.         trail = Instance.new("Trail")
  833.         trail.FaceCamera = true
  834.         trail.LightEmission = 1
  835.         trail.Color = ColorSequence.new(Color3.new(1,0.7,0))
  836.         trail.Transparency = NumberSequence.new({
  837.             NumberSequenceKeypoint.new(0,0),
  838.             NumberSequenceKeypoint.new(0.5,0),
  839.             NumberSequenceKeypoint.new(1,1)
  840.         })
  841.         trail.WidthScale = NumberSequence.new({
  842.             NumberSequenceKeypoint.new(0,1),
  843.             NumberSequenceKeypoint.new(1,0)})
  844.         trail.Lifetime = 3
  845.         trail.Parent = p
  846.         trail.Attachment0 = attach
  847.         trail.Attachment1 = attach2
  848.         if special ~= nil then
  849.             indicate(p, special.Color, special.Text, 1.25)
  850.             pf.Color = special.Color
  851.             p.Color = Color3.new(1, 1, 0.7)
  852.         else
  853.             indicate(p, Color3.new(1, 0.7, 0), "!", 1.25)
  854.             pf.Color = Color3.new(1, 0.7,  0)
  855.         end
  856.         table.insert(movingEnemies, {p, Vector3.new(0, 10, 4),
  857.         (function(h)
  858.             if (h.Name == "RacetrackFloor" or (not h:IsDescendantOf(script))) and (h ~= workspace.Base) and (h ~= pf) then
  859.                 p.Parent = nil
  860.                 pos = p.Position
  861.                 local p2 = Instance.new("SpawnLocation")
  862.                 p2.Material = "Neon"
  863.                 p2.Neutral = false
  864.                 p2.Massless = true
  865.                 p2.Position = pos
  866.                 p2.Anchored = true
  867.                 p2.CanCollide = false
  868.                 p2.Transparency = 0
  869.                 p2.CastShadow = false
  870.                 p2.Size = Vector3.new(size, size, size)*20
  871.                 if special ~= nil then
  872.                     p2.Color = pf.Color
  873.                 else
  874.                     p2.Color = p.Color
  875.                 end
  876.                 p2.Shape = "Ball"
  877.                 spawn(function()
  878.                     for i = 1, 10 do
  879.                         p2.Transparency = i/10
  880.                         swait()
  881.                     end
  882.                     p2:Remove()
  883.                     wait(3)
  884.                     p.Position = p.OriginalPlace.Value
  885.                     p.Parent = script
  886.                 end)
  887.                 effected = {}
  888.                 for _, player in pairs(participants) do
  889.                         dist = player:DistanceFromCharacter(p2.Position)
  890.                     if dist <= size*10*2 and not effected[player.Name] then
  891.                         effected[player.Name] = true
  892.                         bv = Instance.new("BodyVelocity")
  893.                         bv.Velocity = Vector3.new(math.random(-1000, 1000), math.random(0, 200), math.random(-1000, 1000))
  894.                         bv.MaxForce = Vector3.new(1e9, 1e9, 1e9)
  895.                         pcall(function()
  896.                             bv.Parent = player.Character.Head  
  897.                         end)
  898.                         Repped:FireClient(player, "SFX", {ID = 6817150074, Loudness = 0.5})
  899.                         game.Debris:AddItem(bv, 0.2)
  900.                     end
  901.                 end
  902.                 p2.Parent = script
  903.             end
  904.         end)})
  905.         local pos = nil
  906.     end
  907.     p.Parent = enemyFol
  908.     return p
  909. end
  910.  
  911. local obstacle = function(obstacleType, CFplace, size, dedPath)
  912.     local p
  913.     if obstacleType == "yeetLevel1" then
  914.         p = Instance.new("WedgePart")
  915.         p.Color = Color3.new(0.25, 0.1, 1)
  916.         p.Size = Vector3.new(size*4, 10, size+5)
  917.     elseif obstacleType == "yeetLevel2" then
  918.         p = Instance.new("WedgePart")
  919.         p.Color = Color3.new(0.1, 0.25, 1)
  920.         p.Size = Vector3.new(size*4, 25, size+30)
  921.     elseif obstacleType == "yeetLevel3" then
  922.         p = Instance.new("WedgePart")
  923.         p.Color = Color3.new(0.1, 1, 1)
  924.         p.Size = Vector3.new(size*4, 40, size+70)
  925.     else
  926.         p = Instance.new("Part")
  927.         p.Size = Vector3.new(size, size, size)
  928.     end
  929.     p.Material = "Glass"
  930.     p.Massless = true
  931.     p.Anchored = true
  932.     p.CanCollide = true
  933.     p.Transparency = 0
  934.     p.CFrame = CFplace
  935.     local physProperties = PhysicalProperties.new(Enum.Material.Ice)
  936.     p.CustomPhysicalProperties = physProperties
  937.     local assignmentVar = Instance.new("ObjectValue")
  938.     assignmentVar.Name = "DedicatedPath"
  939.     assignmentVar.Value = p
  940.     assignmentVar.Parent = dedPath or nil
  941.     p.Parent = obstacleFol
  942.     return p
  943. end
  944.  
  945. for _,v in pairs(workspace:GetDescendants()) do
  946.     if v:FindFirstChild("lastpart") then
  947.         las = v
  948.     end
  949. end
  950.  
  951.  
  952.  
  953. function NEWPATH(length)
  954.     obstacleFol.Parent = nil
  955.     enemyFol.Parent = nil
  956.     FOL.Parent = nil
  957.     Repped:FireAllClients("reset")
  958.     movingEnemies = {}
  959.     script:ClearAllChildren()
  960.     obstacleFol:ClearAllChildren()
  961.     enemyFol:ClearAllChildren()
  962.     FOL:ClearAllChildren()
  963.    
  964.     obstacleFol.Parent = script
  965.     enemyFol.Parent = script
  966.     FOL.Parent = script
  967.  
  968.     path = Instance.new("SpawnLocation")
  969.     path.Neutral = false
  970.     path.Name = "RacetrackFloor"
  971.     path.Size = Vector3.new(500, 10, 700)
  972.     path.Material = themes[theme]["RoadMaterial"]
  973.     path.Color = themes[theme]["RoadColor"]
  974.     path.Anchored = true
  975.     path.Position = Vector3.new(0,1000,1000)
  976.  
  977.     new = {}
  978.     participants = {}
  979.     READYSETGO = "READY"
  980.     raceline = Instance.new("SpawnLocation")
  981.     raceline.Neutral = false
  982.     raceline.Size = Vector3.new(500, 11, 20)
  983.     raceline.Material = "Neon"
  984.     raceline.BrickColor = BrickColor.new("Daisy orange")
  985.     raceline.Anchored = true
  986.     raceline.Position = Vector3.new(0,1000,900)
  987.     raceline.CastShadow = false
  988.     blockingwall = Instance.new("SpawnLocation")
  989.     blockingwall.Neutral = false
  990.     blockingwall.Size = Vector3.new(700, 700, 20)
  991.     blockingwall.Material = "Neon"
  992.     blockingwall.BrickColor = BrickColor.new("Persimmon")
  993.     blockingwall.Anchored = true
  994.     blockingwall.Position = Vector3.new(0,1000,920)
  995.     blockingwall.Transparency = 0.75
  996.     blockingwall.CastShadow = false
  997.     raceline.Parent = script
  998.     blockingwall.Parent = script
  999.    
  1000.     Repped:FireAllClients("maptype", {
  1001.         Custom = themes[theme].Cust.Start,
  1002.         Track = themes[theme].Cust.Name,
  1003.         CustomEnd = themes[theme].Cust.End})
  1004.     connectedLine = raceline.Touched:Connect(function(h)
  1005.         if h.Parent and h.Parent:FindFirstChildOfClass("Humanoid") and game.Players:FindFirstChild(h.Parent.Name) and not participants[game.Players:GetPlayerFromCharacter(h.Parent).Name] then
  1006.             if h.Parent:FindFirstChild("Participating") then
  1007.                 return
  1008.             else
  1009.                 participating = Instance.new("BoolValue", h.Parent)
  1010.                 participating.Name = "Participating"
  1011.                 if (not game.Players:GetPlayerFromCharacter(h.Parent).PlayerGui:FindFirstChild("RacingUI")) or (game.Players:GetPlayerFromCharacter(h.Parent).PlayerGui:FindFirstChild("RacingUI") and not h.Parent:FindFirstChild("Participating")) then
  1012.                     name = game.Players:GetPlayerFromCharacter(h.Parent).Name
  1013.                     participants[name] = game.Players:FindFirstChild(name)
  1014.                     pcall(function()
  1015.                         game.Players:GetPlayerFromCharacter(h.Parent).PlayerGui:FindFirstChild("RacingUI"):Remove()
  1016.                     end)
  1017.                     local newUi = ui:Clone()
  1018.                     newUi.Parent = game.Players:FindFirstChild(name).PlayerGui
  1019.                     NLS(UiNLS, newUi)
  1020.                 end
  1021.                 print("New Participant: "..game.Players:GetPlayerFromCharacter(h.Parent).Name)
  1022.             end
  1023.             local name = game.Players:GetPlayerFromCharacter(h.Parent).Name
  1024.             participants[name] = game.Players:GetPlayerFromCharacter(h.Parent)
  1025.             Repped:FireClient(participants[name], "maptype", {
  1026.                 Custom = themes[theme].Cust.Start,
  1027.                 Track = themes[theme].Cust.Name,
  1028.                 CustomEnd = themes[theme].Cust.End,
  1029.                 Difficulty = (function()
  1030.     local diffVal = difficulty + themes[theme].Difficulty
  1031.     if diffVal <= 3 then
  1032.         return "Easy"
  1033.     elseif diffVal <= 6 then
  1034.         return "Normal"
  1035.     elseif diffVal <= 9 then
  1036.         return "Moderate"
  1037.     elseif diffVal <= 12 then
  1038.         return "Hard"
  1039.     elseif diffVal <= 15 then
  1040.         return "Very Hard"
  1041.     else
  1042.         return nil
  1043.     end
  1044. end)()})
  1045.         end
  1046.     end)
  1047.     spawn(function()
  1048.     repeat
  1049.         if READYSETGO == "SET" then
  1050.             blockingwall.BrickColor = BrickColor.new("Neon orange")
  1051.         end
  1052.         wait()
  1053.     until READYSETGO == "GO"
  1054.     blockingwall.BrickColor = BrickColor.new("Lime green")
  1055.     blockingwall.CanCollide = false
  1056.     connectedLine:Disconnect()
  1057.     end)
  1058.  
  1059.     path.Parent = script
  1060.  
  1061.     pathWall = Instance.new("SpawnLocation")
  1062.     pathWall.Neutral = false
  1063.     pathWall.Size = Vector3.new(100,500,700)
  1064.     pathWall.Material = themes[theme]["WallMaterial"]
  1065.     pathWall.Color = themes[theme]["WallColor"]
  1066.     pathWall.Position = path.Position + Vector3.new(270,0,0)
  1067.     pathWall.Anchored = true
  1068.     pathWall.Parent = script
  1069.     pathWall2 = Instance.new("SpawnLocation")
  1070.     pathWall2.Neutral = false
  1071.     pathWall2.Size = Vector3.new(100,500,700)
  1072.     pathWall2.Material = themes[theme]["WallMaterial"]
  1073.     pathWall2.Color = themes[theme]["WallColor"]
  1074.     pathWall2.Position = path.Position + Vector3.new(-270,0,0)
  1075.     pathWall2.Anchored = true
  1076.     pathWall2.Parent = script
  1077.  
  1078.     local lastp = nil
  1079.  
  1080.     if not las then
  1081.         lastp = Instance.new("BoolValue")
  1082.         lastp.Name = "lastpart"
  1083.     else
  1084.         lastp = las.lastpart
  1085.     end
  1086.    
  1087.     local lastpart = path
  1088.     local loadingtick = tick()
  1089.     for i = 1,length do
  1090.         clone = path:Clone()
  1091.         local uptilt = math.rad(math.random(-5,5))
  1092.         local sidetilt = math.rad(math.random(-1,1)/10)
  1093.         if (path.Position.Y) < 100 then uptilt = math.rad(math.random(5,10)) end
  1094.         if tilt == "off" then uptilt = 0 sidetilt = 0 end
  1095.         clone.CFrame = lastpart.CFrame * CFrame.new(0,math.random(-2,2),500) * CFrame.Angles(sidetilt, math.rad(math.random(-5,5))*(difficulty/10), uptilt)
  1096.         clone.Parent = script
  1097.         clonew = pathWall:Clone()
  1098.         clonew.CFrame = clone.CFrame * CFrame.new(-270,200,0)
  1099.         clonew.Parent = script
  1100.         clonew2 = pathWall2:Clone()
  1101.         clonew2.CFrame = clone.CFrame * CFrame.new(270,200,0)
  1102.         clonew2.Parent = script
  1103.         enemy("fling ghost", clonew.Position + Vector3.new(0, 270, 0), 20, {Text = "(GET DOWN)", Color = Color3.new(0, 0.45, 1), InnerColor = Color3.new(0,0,0)})
  1104.         enemy("fling ghost", clonew2.Position + Vector3.new(0, 270, 0), 20, {Text = "(GET DOWN)", Color = Color3.new(0, 0.45, 1), InnerColor = Color3.new(0,0,0)})
  1105.  
  1106.         if math.random(1, 3) == 1 then
  1107.             enemy("fling ghost", clone.Position + Vector3.new(math.random(-200, 200), math.random(5, 7.5) + 10, math.random(-300, 300)), math.random(1, 5)+10)
  1108.         elseif math.random(1, 3) == 2 then
  1109.             local origin = clone.CFrame * CFrame.new(math.random(-100, 100), math.random(5, 7.5) + 10, math.random(-300, 300))
  1110.             local pos = nil
  1111.             spawn(function()
  1112.                 for i = 1, 10 do
  1113.                     if i > 5 then
  1114.                         pos = origin * CFrame.new(11 * (i-5), 11, 0)
  1115.                     else
  1116.                         pos = origin * CFrame.new(11 * i, 0, 0)
  1117.                     end
  1118.                     enemy("fling ghost", pos.Position, 10)
  1119.                 end
  1120.             end)
  1121.         elseif math.random(1, 3) == 3 then
  1122.             local origin = clone.CFrame * CFrame.new(math.random(-100, 100), math.random(5, 7.5) + 10, math.random(-300, 300))
  1123.             local pos = nil
  1124.             spawn(function()
  1125.                 for i = 1, 20 do
  1126.                     if i > 15 then
  1127.                         pos = origin * CFrame.new(11 * (i-15), 33, 0)
  1128.                     elseif i > 10 then
  1129.                         pos = origin * CFrame.new(11 * (i-10), 22, 0)
  1130.                     elseif i > 5 then
  1131.                         pos = origin * CFrame.new(11 * (i-5), 11, 0)
  1132.                     else
  1133.                         pos = origin * CFrame.new(11 * i, 0, 0)
  1134.                     end
  1135.                     enemy("fling ghost", pos.Position, 10)
  1136.                 end
  1137.             end)
  1138.         end
  1139.         if math.random(1, 3) == 1 then
  1140.             obstacle("yeetLevel"..math.random(1, 2), clone.CFrame*CFrame.new(math.random(-(clone.Size.X/2)+20, (clone.Size.X/2)-20), 1 + clone.Size.Y/2, math.random(-(clone.Size.Z/2), (clone.Size.Z/2))), math.random(1, 10)+30, clone)
  1141.         end
  1142.         themes[theme]["Extra"](clone, false)
  1143.         lastp.Parent = clone
  1144.         lastpart = clone
  1145.         if tick() - loadingtick >= 1 then
  1146.             print("Progress: Sector "..i.."/"..length)
  1147.             loadingtick = tick()
  1148.         end
  1149.         --swait(spawnInterval)
  1150.     end
  1151.  
  1152.     local finish = Instance.new("SpawnLocation")
  1153.     finish.Neutral = false
  1154.     finish.Size = Vector3.new(700,700,700)
  1155.     finish.Material = "Neon"
  1156.     finish.Color = Color3.new(0, 1, 0.367)
  1157.     finish.CFrame = lastpart.CFrame * CFrame.new(0,0,500)
  1158.     finish.Anchored = true
  1159.     finish.Parent = script
  1160.     finish.CanCollide = false
  1161.     finish.Name = "The End"
  1162.  
  1163.     local end1 = Instance.new("StringValue")
  1164.     end1.Name = "Finished"
  1165.     end1.Value = ""
  1166.     end1.Parent = finish
  1167.  
  1168.     local end2 = Instance.new("StringValue")
  1169.     end2.Name = "Finished2"
  1170.     end2.Value = ""
  1171.     end2.Parent = finish
  1172.  
  1173.     local end3 = Instance.new("StringValue")
  1174.     end3.Name = "Finished3"
  1175.     end3.Value = ""
  1176.     end3.Parent = finish
  1177.  
  1178.     finish.Touched:Connect(function(h)
  1179.         if READYSETGO == "GO" and h.Parent and h.Parent:FindFirstChildOfClass("Humanoid") and game.Players:FindFirstChild(h.Parent.Name) and (end1.Value == "" or end2.Value == "" or end3.Value == "") then
  1180.             name = game.Players:GetPlayerFromCharacter(h.Parent).Name
  1181.             if not participants[name] then return end
  1182.             if end1.Value ~= "" then
  1183.                 if end2.Value ~= "" then
  1184.                     if end3.Value ~= "" then
  1185.                     elseif end3.Value == "" and name ~= end2.Value and name ~= end1.Value then
  1186.                         end3.Value = name
  1187.                         print("Winner 3: "..name)
  1188.                         finish.Color = Color3.new(0.7, 0.28, 0)
  1189.                         finishEffect(finish, "Its over! "..name.." takes third place!",  CSEQ(RGB(255/0.7, 255/0.28, 0)), game.Players:GetPlayerFromCharacter(h.Parent))
  1190.                         tween(finish, {Color = Color3.new(0, 1, 0.367)}, {Time = 2, Style = Enum.EasingStyle.Cubic, Direction = Enum.EasingDirection.In, Repeat = 0, Reverses = false, Delay = 0})
  1191.  
  1192.                     end
  1193.                 elseif end2.Value == "" and name ~= end1.Value then
  1194.                     end2.Value = name
  1195.                     print("Winner 2: "..name)
  1196.                     finish.Color = Color3.new(0.5, 0.5, 0.5)
  1197.                     finishEffect(finish, "Nice job! "..name.." came second!", CSEQ(RGB(255, 255, 255)), game.Players:GetPlayerFromCharacter(h.Parent))
  1198.                     tween(finish, {Color = Color3.new(0, 1, 0.367)}, {Time = 2, Style = Enum.EasingStyle.Cubic, Direction = Enum.EasingDirection.In, Repeat = 0, Reverses = false, Delay = 0})
  1199.                 end
  1200.             else
  1201.                 end1.Value = name
  1202.                 print("Winner 1: "..name)
  1203.                 finish.Color = Color3.new(1, 0.7, 0.3)
  1204.                 finishEffect(finish, "YES! "..name.." takes first place!", nil, game.Players:GetPlayerFromCharacter(h.Parent))
  1205.                 tween(finish, {Color = Color3.new(0, 1, 0.367)}, {Time = 2, Style = Enum.EasingStyle.Cubic, Direction = Enum.EasingDirection.In, Repeat = 0, Reverses = false, Delay = 0})
  1206.             end
  1207.         end
  1208.     end)
  1209.  
  1210.     print("Path finished")
  1211.  
  1212. end
  1213.  
  1214. ------------------------------------------------------Sound and Theme extra
  1215.  
  1216. function updsound(override)
  1217.     Repped:FireAllClients("music", {CMD = override})
  1218. end
  1219.  
  1220. themes = {
  1221.     normal = {RoadColor = Color3.new(0.3,0.3,0.3),
  1222.         RoadColor2 = Color3.new(0.2,0.2,0.45),
  1223.         WallColor = Color3.new(1,1,0.7),
  1224.         WallColor2 = Color3.new(1,1,0.7),
  1225.         RoadMaterial = "Slate",
  1226.         RoadMaterial2 = "Cobblestone",
  1227.         WallMaterial = "Sand",
  1228.         WallMaterial2 = "Sand",
  1229.         Difficulty = 1,
  1230.         Extra = function(currentPath)
  1231.            
  1232.            
  1233.         end,
  1234.         Cust = {Start = '<font face="Arcade"><font color="rgb(255,165,0)">',
  1235.             End = '</font></font>',
  1236.             Name = "Rogue Roadways"}},
  1237.    
  1238.     starry = {RoadColor = Color3.new(0.1,0.1,0.2),
  1239.         RoadColor2 = Color3.new(0,0,0.1),
  1240.         WallColor = Color3.new(0.1,0.1,0.2),
  1241.         WallColor2 = Color3.new(0,0,0.1),
  1242.         RoadMaterial = "Neon",
  1243.         RoadMaterial2 = "Neon",
  1244.         WallMaterial = "Neon",
  1245.         WallMaterial2 = "Neon",
  1246.         Difficulty = 1,
  1247.         Extra = function(currentPath)
  1248.             local randPos = currentPath.Position + Vector3.new(
  1249.                 math.random(-(currentPath.Size.X/2), currentPath.Size.X/2),
  1250.                 math.random(450, 500),
  1251.                 math.random(-(currentPath.Size.Z/2), currentPath.Size.Z/2))
  1252.             spawn(function()
  1253.                 wait(math.random(3))
  1254.                 enemy("starfall fling", randPos, 7)
  1255.             end)
  1256.         end,
  1257.         Cust = {Start = '<font face="Fantasy"><font color="rgb(1, 0, 50)">',
  1258.             End = '</font></font>',
  1259.             Name = "Starlight Stormfront"}},
  1260.  
  1261.  
  1262.     grass = {RoadColor = Color3.new(0.3,0.6,0.3),
  1263.         RoadColor2 = Color3.new(0,0.3,0.1),
  1264.         WallColor = Color3.new(0.4,0.5,0.4),
  1265.         WallColor2 = Color3.new(0,0.5,0.2),
  1266.         RoadMaterial = "Grass",
  1267.         RoadMaterial2 = "Cobblestone",
  1268.         WallMaterial = "Pebble",
  1269.         WallMaterial2 = "Marble",
  1270.         Difficulty = 2,
  1271.         Extra = function(currentPath, alt)
  1272.             if math.random(1, 5) ~= 1 then
  1273.                 pathLedge = Instance.new("SpawnLocation")
  1274.                 pathLedge.Neutral = false
  1275.                 pathLedge.Size = Vector3.new(500, math.random(10, 30), math.random(100, 500))
  1276.                 if alt == false then
  1277.                     pathLedge.Material = "Pebble"
  1278.                 else
  1279.                     pathLedge.Material = "Marble"
  1280.                 end
  1281.                 if alt == false then
  1282.                     pathLedge.Color = Color3.new(0.4,0.5,0.4)
  1283.                 else
  1284.                     pathLedge.Color = Color3.new(0,0.5,0.2)
  1285.                 end
  1286.                 pathLedge.Anchored = true
  1287.                 chosenRandom = math.random(300, 450)
  1288.                 pathLedge.CFrame = currentPath.CFrame * CFrame.new(0, chosenRandom, 0)
  1289.                 pathLedge.Parent = currentPath
  1290.                 specInterval = specInterval+1
  1291.                 if specInterval == 10 then
  1292.                     local positions = {Tree1 = {false, -200}, Tree2 = {false, -100}, Tree3 = {false, 0}, Tree4 = {false, 100}, Tree5 = {false, 200}}
  1293.                     specInterval = 0
  1294.                     for i = 1,3 do
  1295.                         local a
  1296.                         repeat a = math.random(1, 5) until positions["Tree"..a][1] == false
  1297.                         positions["Tree"..a][1] = true
  1298.                         tree = Instance.new("SpawnLocation")
  1299.                         tree.Neutral = false
  1300.                         tree.Size = Vector3.new(math.random(50, 70), chosenRandom-1, math.random(50, 70))
  1301.                         tree.Color = BrickColor.new("Burnt Sienna").Color
  1302.                         tree.Material = "Wood"
  1303.                         tree.Anchored = true
  1304.                         tree.CFrame = currentPath.CFrame * CFrame.new(positions["Tree"..a][2], (currentPath.Size.Y/2) + (chosenRandom/2), 0)
  1305.                         tree.Parent = currentPath
  1306.                         treeP2 = Instance.new("SpawnLocation")
  1307.                         treeP2.Neutral = false
  1308.                         treeP2.Size = Vector3.new(tree.Size.X + 5, currentPath.Size.Y + 7.5, tree.Size.Z + 5)
  1309.                         treeP2.Color = BrickColor.new("Burnt Sienna").Color
  1310.                         treeP2.Material = "Wood"
  1311.                         treeP2.Anchored = true
  1312.                         treeP2.CFrame = CFrame.new(tree.CFrame.X, currentPath.CFrame.Y, tree.CFrame.Z) 
  1313.                         treeP2.Orientation = Vector3.new(0, tree.Orientation.Y, 0)
  1314.                         treeP2.Parent = tree
  1315.                     end
  1316.                 end
  1317.             end
  1318.         end,
  1319.         Cust = {Start = '<font face="Antique"><font color="rgb(0,165,0)">',
  1320.             End = '</font></font>',
  1321.             Name = "Filthy Forest"}}}
  1322.  
  1323.  
  1324. ------------------------------------------------------------------------Host/Player/Owner interactivity
  1325.  
  1326. owner.Chatted:Connect(function(c)
  1327.     local c = c
  1328.     if string.sub(c, 1, string.len(prefix)) == prefix then
  1329.         c = string.sub(c, 2):lower()
  1330.         if c == "start" then
  1331.             READYSETGO = "ON YOUR MARKS"
  1332.             Repped:FireAllClients("readyset", {Text = "-3- ON YOUR MARKS -3-", Color = Color3.new(1, 0, 0)})
  1333.             READYSETGO = "ON YOUR MARKS"
  1334.             wait(1)
  1335.             Repped:FireAllClients("readyset", {Text = "-2- GET READY -2-", Color = Color3.new(1, 0.3, 0)})
  1336.             READYSETGO = "READY"
  1337.             wait(1)
  1338.             Repped:FireAllClients("readyset", {Text = "-1- SET -1-", Color = Color3.new(1, 0.7, 0)})
  1339.             READYSETGO = "SET"
  1340.             wait(1)
  1341.             Repped:FireAllClients("go")
  1342.             READYSETGO = "GO"
  1343.         elseif string.sub(c, 1, 10) == "maketrack " then
  1344.             c = string.sub(c, 11)
  1345.             if c == "grass" then
  1346.                 theme = "grass"
  1347.                 NEWPATH(200)
  1348.             elseif c == "starry" then
  1349.                 theme = "starry"
  1350.                 NEWPATH(200)
  1351.             else
  1352.                 theme = "normal"
  1353.                 NEWPATH(200)
  1354.             end
  1355.         elseif string.sub(c, 1, 3) == "id " then
  1356.             soundID = string.sub(c, 4)
  1357.             Mastersound.SoundId = "rbxassetid://"..soundID
  1358.             updsound("Change Id")
  1359.         elseif string.sub(c, 1, 7) == "prefix " then
  1360.             prefix = string.sub(c, 8)
  1361.         elseif string.sub(c, 1, 5) == "diff " then
  1362.             difficulty = tonumber(string.sub(c, 6))
  1363.         elseif string.sub(c, 1, 5) == "tilt " then
  1364.             c = string.sub(c, 6)
  1365.             if c == "on" or c == "true" then
  1366.                 tilt = true
  1367.             elseif c == "off" or c == "false" then
  1368.                 tilt = false
  1369.             end
  1370.         elseif c == "play" then
  1371.             updsound("Play")
  1372.         elseif c == "pause" then
  1373.             updsound("Stop Playing")
  1374.         elseif c == "resume" then
  1375.             updsound("Keep Playing")
  1376.         end
  1377.     end
  1378. end)
  1379.  
  1380. print("(UI Lock must be disabled.)")
  1381. print("(Prefix: "..prefix..")")
  1382. print([[Command List (prefix excluded):
  1383.  
  1384. maketrack - Prompts the creation of the race track. Please only run once per script, or chaos will ensue (|||_  _)
  1385. play - Plays the current music id on every player's ui.
  1386. pause - Pauses the current music id on every player's ui.
  1387. resume - Resumes the current music id on every player's ui.
  1388. id - Changes the current music id for everyone.
  1389. start - Begins the race for everyone participating.
  1390. prefix - Changes the prefix of the script.
  1391. diff - Changes difficulty of the race. (1-10 suggested.)
  1392. tilt - Turns track tilting on/off. (on/off or true/false)
  1393.  
  1394. (Once the race has started, no one else can join.)
  1395.  
  1396. ]])
  1397. print("Available races: \n")
  1398. for i,v in pairs(themes) do
  1399.     print(i.." - ("..v.Cust.Name..")")
  1400. end
  1401.  
  1402. ---------------------------------------------------------------Final WHILE loop for race
  1403.  
  1404. spawn(function()
  1405.     while true do
  1406.         for i = 0,1,1/350 do
  1407.             swait()
  1408.             ShiftingColor = Color3.fromHSV(i,1,1)
  1409.         end
  1410.     end
  1411. end)
  1412.  
  1413.  
  1414. local function castRay(startPos, endPos)
  1415.     local results = workspace:Raycast(startPos, endPos)
  1416.     if results then
  1417.         return results
  1418.     else return nil
  1419.     end
  1420. end
  1421. game:GetService("RunService").Stepped:Connect(function()
  1422.     for i,item in pairs(movingEnemies) do
  1423.         if item[1] and item[1]:IsDescendantOf(workspace) then
  1424.             local res = castRay(item[1].Position, item[1].Position - item[2])
  1425.             if res and res.Instance then
  1426.                 item[3](res.Instance)
  1427.             end
  1428.             item[1].Position = item[1].Position - item[2]
  1429.         end
  1430.     end
  1431. end)
  1432.  
  1433. while true do
  1434.     new = {}
  1435.     if READYSETGO == "GO" then
  1436.         for i,v in pairs(participants) do
  1437.             if v.Character:FindFirstChild("Participating") then
  1438.                 table.insert(new, {i, math.floor((v.Character.Head.Position - script["The End"].Position).Magnitude)/20})
  1439.                 Repped:FireClient(v, "distance", {
  1440.                     Distance = math.floor((v.Character.Head.Position - script["The End"].Position).Magnitude)/20})
  1441.             else
  1442.                 v.PlayerGui.RacingUI:Remove()
  1443.                 participants[i] = nil
  1444.             end
  1445.         end
  1446.         table.sort(new, function(a, b) return a[2]<b[2] end)
  1447.     end
  1448.     for _,v in pairs(colorChanging) do
  1449.         pcall(function()
  1450.             v.Color = ShiftingColor
  1451.         end)
  1452.         pcall(function()
  1453.             v.TextStrokeColor3 = ShiftingColor
  1454.             v.TextColor3 = Color3.new(1, 1, 1)
  1455.         end)
  1456.     end
  1457.     wait()
  1458. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement