Advertisement
EmeraldIT

Race Track

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