Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- version = "0.1"
- -------------------------------------------------Clean up of old scripts + credit
- if workspace:FindFirstChild("The Race") then
- workspace["The Race"]:Remove()
- end
- script.Name = "The Race"
- print("This script was made by Rese#2110 - based off of a script made by DevSersponge a long time ago.\nMost recent version: "..version)
- -------------------------------------------------Value/Key variable assignment and initiation
- local TweenService = game:GetService("TweenService")
- local pla = owner
- local wo = workspace
- local las = nil
- local theme = "normal"
- local themes = {}
- local difficulty = 10 --1, 10
- local tilt = "off"
- local spawnInterval = 0
- local specInterval = 0
- local participants = {}
- local soundID = "7568675939"
- local raceline = nil
- local READYSETGO = "READY"
- local prefix = "!"
- local connectedLine = nil
- local new = {}
- local colorChanging = {}
- local ShiftingColor = Color3.new(1, 1, 1)
- local obstacleFol = Instance.new("Folder", script)
- local enemyFol = Instance.new("Folder", script)
- local FOL = Instance.new("Folder", script)
- local PLR = pla
- local CHA = PLR.Character
- local MO = Mouse
- local HOLD = false
- local CF = CFrame.new
- local ANG = CFrame.Angles
- local RAN = math.random
- local C3 = Color3.new
- local RGB = Color3.fromRGB
- local VT = Vector3.new
- local UD = UDim2.new
- local SEQ = NumberSequence.new
- local CSEQ = ColorSequence.new
- local NKEY = NumberSequenceKeypoint.new
- local CKEY = ColorSequenceKeypoint.new
- local RANGE = NumberRange.new
- -------------------------------------------------------------UI, sound and NLS stuff
- local ui = Instance.new("ScreenGui")
- local Mastersound = game.ReplicatedStorage:FindFirstChild("MasterSound") or Instance.new("Sound")
- local distance = Instance.new("TextLabel")
- local points = Instance.new("TextLabel")
- local place = Instance.new("TextLabel")
- local modeindicator = Instance.new("TextLabel")
- local songindicator = Instance.new("TextLabel")
- local notif = Instance.new("TextLabel")
- local countdown = Instance.new("TextLabel")
- local Repped = Instance.new("RemoteEvent")
- Repped.Name = "SoundEvent"
- distance.Text = "Distance till end: "
- distance.Name = "Distance"
- points.Text = "Points: "
- points.Name = "Points"
- place.Text = "Rank: "
- place.Name = "Place"
- modeindicator.Text = "Race track: "
- modeindicator.Name = "ModeIndicator"
- songindicator.Text = "Music playing: "
- songindicator.Name = "SongIndicator"
- notif.Text = ""
- notif.Name = "Notification"
- countdown.Text = "- STOP -"
- countdown.Name = "Countdown"
- Mastersound.Name = "MasterSound"
- Mastersound.SoundId = "rbxassetid://"..soundID
- Mastersound.Playing = false
- Mastersound.Volume = 1
- Mastersound.Looped = true
- Mastersound.Parent = game.ReplicatedStorage
- Repped.Parent = Mastersound
- local sound = Mastersound:Clone()
- sound.Parent = ui
- sound.Playing = false
- sound.Name = "RepSound"
- ui.Name = "RacingUI"
- local labelsframe = Instance.new("Frame")
- labelsframe.Size = UDim2.new(.15, 0, .4, 0)
- labelsframe.BackgroundTransparency = 1
- labelsframe.AnchorPoint = Vector2.new(0, 0.5)
- labelsframe.Position = UDim2.new(0, 0, 0.5, 0)
- local bevel = Instance.new("UIStroke")
- bevel.ApplyStrokeMode = "Border"
- bevel.LineJoinMode = "Bevel"
- bevel.Thickness = 4
- bevel.Color = Color3.new(0.3, 0.3, 0.3)
- local corner = Instance.new("UICorner")
- distance.Parent = labelsframe
- points.Parent = labelsframe
- place.Parent = labelsframe
- modeindicator.Parent = labelsframe
- songindicator.Parent = labelsframe
- local maxTextSize = Instance.new("UITextSizeConstraint")
- maxTextSize.MaxTextSize = 35
- countdown.Size = UDim2.new(0.3, 0, 0.1, 0)
- countdown.AnchorPoint = Vector2.new(0.5, 0.5)
- countdown.Position = UDim2.new(0.5, 0, -1, 0)
- countdown.TextColor3 = Color3.new(1, 0, 0)
- countdown.Parent = ui
- countdown.Name = "Countdown"
- labelsframe.Parent = ui
- local yes = 0
- for _,v in pairs(ui:GetDescendants()) do
- if v:IsA("TextLabel") then
- v.TextScaled = true
- v.TextStrokeColor3 = Color3.new(0, 0, 0)
- v.TextStrokeTransparency = 0
- v.BackgroundTransparency = 1
- v.AnchorPoint = Vector2.new(.5, .5)
- v.RichText = true
- v.Font = "SciFi"
- maxTextSize:Clone().Parent = v
- if v == countdown then
- v.Font = "Arcade"
- end
- if v.Parent == labelsframe then
- v.Size = UDim2.new(1, 0, 0.15, 0)
- bevel:Clone().Parent = v
- corner:Clone().Parent = v
- v.BackgroundTransparency = 0.9
- v.TextColor3 = Color3.new(1, 1, 1)
- v.BackgroundColor3 = Color3.new(1, 1, 1)
- v.TextXAlignment = "Left"
- v.Position = UDim2.new(-1, 0, 0.22*yes, 0)
- yes = yes + 1
- end
- end
- end
- UiNLS = [[
- local ui = script.Parent
- local Mastersound = game.ReplicatedStorage.MasterSound
- local MarketPlaceService = game:GetService("MarketplaceService")
- local labelsframe = ui.Frame
- local distance = labelsframe.Distance
- local points = labelsframe.Points
- local place = labelsframe.Place
- local modeindicator = labelsframe.ModeIndicator
- local songindicator = labelsframe.SongIndicator
- local countdown = ui.Countdown
- local sound = ui.RepSound
- local repped = Mastersound:WaitForChild("SoundEvent")
- local TweenService = game:GetService("TweenService")
- local tween = function(part, info, tweeninfo)
- local yes = 0
- local tweenInfo = TweenInfo.new(
- tweeninfo.Time, -- Time
- tweeninfo.Style, -- EasingStyle
- tweeninfo.Direction, -- EasingDirection
- tweeninfo.Repeat, -- RepeatCount (when less than zero the tween will loop indefinitely)
- tweeninfo.Reverses, -- Reverses (tween will reverse once reaching it's goal)
- tweeninfo.Delay -- DelayTime
- )
- local tween = TweenService:Create(part, tweenInfo, info)
- tween:Play()
- return tween
- end
- local mode = "ready"
- function refreshUi()
- yes = 0
- for i,v in pairs(ui.Frame:GetChildren()) do
- if v:IsA("TextLabel") then
- v.Position = UDim2.new(-1, 0, 0.22*yes, 0)
- yes = yes + 1
- end
- end
- yes = 0
- ui.Countdown.Position = UDim2.new(0.5, 0, -1, 0)
- 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})
- for i,v in pairs(ui.Frame:GetChildren()) do
- if v:IsA("TextLabel") then
- 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})
- yes = yes + 1
- wait(0.2)
- end
- end
- end
- function checkSou(detail)
- if detail == "Play" then
- detail = true
- sound.TimePosition = 0
- elseif detail == "Keep Playing" then
- detail = true
- elseif detail == "Stop Playing" then
- detail = false
- elseif detail == "Change Id" then
- sound.SoundId = Mastersound.SoundId
- detail = sound.Playing
- end
- local success, asset = pcall(MarketPlaceService.GetProductInfo,MarketPlaceService, string.sub(Mastersound.SoundId, string.len("rbxassetid://")+1))
- songindicator.Text = "Music playing: "..(asset.Name or "None").." - "..string.sub(Mastersound.SoundId, string.len("rbxassetid://")+1)
- sound.Volume = Mastersound.Volume
- sound.Playing = detail
- end
- local makeSou = function(parent, id, vol, play, playOnRemove)
- local Sound = Instance.new("Sound")
- Sound.Volume = vol
- Sound.SoundId = id
- if playOnRemove then
- Sound.PlayOnRemove = true
- end
- Sound.Parent = parent or workspace
- if play then
- Sound:Play()
- end
- return Sound
- end
- owner.Character.Destroying:Connect(function()
- ui:Remove()
- script.Disabled = true
- end)
- owner.Character:FindFirstChildOfClass("Humanoid").Died:Connect(function()
- ui:Remove()
- script.Disabled = true
- end)
- local playing = false
- local Testingtick = tick()
- repped.OnClientEvent:Connect(function(typeOfUpdate, details)
- if typeOfUpdate == "points" then
- points.Text = "Points: "..details.Points
- elseif typeOfUpdate == "place" then
- local newT = {}
- local num = 0
- for i, v in pairs(details) do
- num = num + 1
- local pos = v[1]
- newT[pos] = num
- end
- YourRank = newT[owner.Name]
- if YourRank == 1 then
- 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>'
- elseif YourRank == 2 then
- 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>'
- elseif YourRank == 3 then
- 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>'
- else
- place.Text = "Rank: <b>"..YourRank.."th".."</b>"
- end
- elseif typeOfUpdate == "distance" then
- distance.Text = "Distance till end: "..details.Distance.." meters"
- elseif typeOfUpdate == "maptype" then
- refreshUi()
- checkSou(false)
- modeindicator.Text = "Race track: <b>"..details.Custom..details.Track..details.CustomEnd.."</b>"
- elseif typeOfUpdate == "music" then
- detail = details.CMD
- checkSou(detail)
- elseif typeOfUpdate == "readyset" then
- makeSou(ui, "rbxassetid://5448028218", 0.5, true)
- mode = typeOfUpdate
- countdown.Text = details.Text
- tween(countdown, {TextColor3 = details.Color}, {Time = 0.4, Style = Enum.EasingStyle.Cubic, Direction = Enum.EasingDirection.InOut, Repeat = 0, Reverses = false, Delay = 0})
- elseif typeOfUpdate == "go" then
- makeSou(ui, "rbxassetid://538405084", 0.5, true)
- playing = false
- mode = typeOfUpdate
- countdown.Text = "! GO !"
- 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})
- wait(0.25)
- 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})
- elseif typeOfUpdate == "SFX" then
- makeSou(ui, "rbxassetid://"..details.ID, details.Loudness or 0.5, true)
- end
- end)
- game:GetService("RunService").RenderStepped:Connect(function()
- if mode == "go" and owner.Character and owner.Character:FindFirstChild("Participating") then
- owner.Character.Humanoid.WalkSpeed = 1000
- end
- if not owner.Character:FindFirstChild("Participating") then
- ui:Remove()
- script.Disabled = true
- end
- end)
- ]]
- ---------------------------------------------------------------Useful functions
- local tween = function(part, info, tweeninfo)
- local tweenInfo = TweenInfo.new(
- tweeninfo.Time, -- Time
- tweeninfo.Style, -- EasingStyle
- tweeninfo.Direction, -- EasingDirection
- tweeninfo.Repeat, -- RepeatCount (when less than zero the tween will loop indefinitely)
- tweeninfo.Reverses, -- Reverses (tween will reverse once reaching it's goal)
- tweeninfo.Delay -- DelayTime
- )
- local tween = TweenService:Create(part, tweenInfo, info)
- tween:Play()
- return tween
- end
- local makeSou = function(parent, id, vol, play, playOnRemove)
- local Sound = Instance.new("Sound")
- Sound.Volume = vol
- Sound.SoundId = id
- if playOnRemove then
- Sound.PlayOnRemove = true
- end
- Sound.Parent = parent or workspace
- if play then
- Sound:Play()
- end
- return Sound
- end
- local indicate = function(part, color, texthere, size)
- local indi = Instance.new("SpawnLocation")
- indi.Neutral = false
- indi.Size = Vector3.new(.01, .01, .01)
- indi.Transparency = 1
- indi.CanCollide = false
- indi.Massless = true
- if not size then
- size = 1
- end
- local holdingUI = Instance.new("BillboardGui")
- holdingUI.Parent = indi
- holdingUI.Adornee = indi
- holdingUI.AlwaysOnTop = true
- holdingUI.MaxDistance = 700
- holdingUI.Brightness = 1
- holdingUI.Size = UDim2.new(10*size, 0, 10*size, 0)
- holdingUI.StudsOffset = Vector3.new(5, -5, 0)
- holdingUI.DistanceUpperLimit = 1
- holdingUI.DistanceLowerLimit = 100
- local text = Instance.new("TextLabel")
- text.Size = UDim2.new(1, 0, 1, 0)
- text.TextScaled = true
- text.Font = "Arcade"
- text.TextStrokeTransparency = 0
- text.TextStrokeColor3 = Color3.new(0, 0, 0)
- text.TextColor3 = color
- text.BackgroundTransparency = 1
- text.AnchorPoint = Vector2.new(.5, .5)
- text.Text = texthere
- repeat wait() until text.Text == texthere
- text.Parent = holdingUI
- local weld = Instance.new("Weld")
- weld.C0 = CFrame.new(0,0,0)
- weld.Part0 = part
- weld.Part1 = indi
- weld.Parent = indi
- indi.Parent = part
- return text
- end
- local part = function(parent, doesdelete, duration, size, cframe, position, material, transparency, reflectance, anchored, cancollide, shape)
- local p = Instance.new("SpawnLocation")
- --If statements
- if shape and shape == "Sphere" then
- local pm = Instance.new("SpecialMesh")
- pm.MeshType = "Sphere"
- pm.Parent = p
- elseif shape and shape ~= "Sphere" then
- p.Shape = "Block"
- end
- if cframe then
- p.CFrame = cframe
- elseif position then
- p.Position = position
- end
- if doesdelete then
- game.Debris:AddItem(p, duration)
- end
- p.Size = size
- p.Material = material or "Neon"
- p.Neutral = false
- p.Transparency = transparency
- p.Reflectance = reflectance
- p.Anchored = anchored or true
- p.CanCollide = cancollide or false
- p.Parent = parent
- return p
- end
- local pte = function(parent, lightemission, lightinfluence, color, transparency, drag, locked, accel, rate, lifetime, rotspeed, rotation, spread, speed, size, texture, z, direction, enabled)
- local pe = Instance.new("ParticleEmitter")
- pe.LightEmission = lightemission
- pe.LightInfluence = lightinfluence
- pe.Color = color
- pe.Size = size
- pe.Transparency = transparency
- pe.ZOffset = z
- pe.EmissionDirection = direction
- pe.Rate = rate
- pe.LockedToPart = locked
- pe.Acceleration = accel or Vector3.new(0,0,0)
- pe.Lifetime = lifetime
- pe.RotSpeed = rotspeed
- pe.Rotation = rotation
- pe.SpreadAngle = spread
- pe.Speed = speed
- pe.Texture = texture
- pe.Enabled = enabled
- pe.Drag = drag
- pe.Parent = parent
- return pe
- end
- local trail = function(parent, temp, period, texture, col, enabled, turning, lighte, lighti, max, min, textlen, textmode, tran, wids, life)
- local tr = Instance.new("Trail")
- local att = Instance.new("Attachment")
- local att2 = Instance.new("Attachment")
- att.Parent = parent
- att2.Parent = parent
- att.Position = VT(0,parent.Size.Y/2,0)
- att2.Position = VT(0,-parent.Size.Y/2,0)
- tr.Enabled = enabled
- tr.Texture = texture
- tr.Color = col
- tr.FaceCamera = turning
- tr.LightEmission = lighte
- tr.LightInfluence = lighti
- tr.MaxLength = max
- tr.Lifetime = life
- tr.MinLength = min
- tr.TextureLength = textlen
- tr.TextureMode = textmode
- tr.Transparency = tran
- tr.WidthScale = wids
- tr.Attachment0 = att
- tr.Attachment1 = att2
- if temp then
- spawn(function()
- wait(period)
- tr.Enabled = false
- wait(life)
- tr:Destroy()
- end)
- end
- tr.Parent = parent
- return tr
- end
- local virtualize = function(instakill, thing)
- if instakill == true then
- thing.Touched:Connect(function(touched)
- end)
- elseif instakill == false then
- thing.Touched:Connect(function(touched)
- if touched.Parent and touched.Parent:FindFirstChildOfClass("Humanoid") then
- if touched.Parent.Parent and touched.Parent.Parent == CHA then return end
- if touched.Parent:FindFirstChild("STUNNED") then return end
- hum = touched.Parent:FindFirstChildOfClass("Humanoid")
- debo = Instance.new("BoolValue")
- debo.Name = "STUNNED"
- debo.Parent = touched
- game.Debris:AddItem(debo, 3)
- truw = hum.WalkSpeed
- truj = hum.JumpPower
- if hum.MaxHealth >= math.huge then
- spawn(function()
- while true do
- hum.MaxHealth = 100
- wait()
- end
- end)
- end
- spawn(function()
- if (not touched:FindFirstChildOfClass("ParticleEmitter")) and (touched.Name == "Head" or touched.Name == "FakeHead" or touched.Name == "HumanoidRootPart" or touched.Name == "Torso") then
- 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)
- game.Debris:AddItem(pt, 3)
- end
- spawn(function()
- for i = 1,100 do
- hum.WalkSpeed = math.random(1,10)
- hum.JumpPower = math.random(1,20)
- hum.Health = hum.Health - (hum.MaxHealth / 5000)
- wait()
- end
- end)
- hum.WalkSpeed = truw
- hum.JumpPower = truj
- end)
- end
- end)
- end
- end
- local spark = function(origin, time, inc, HARMLESS)
- x = 0
- z = 0
- local p = part(FOL, true, time, VT(1,1,1), nil, origin.Position, "Neon", 1, 0, true, false, nil)
- if not HARMLESS then
- virtualize(false, p)
- end
- 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)
- spawn(function()
- for i = 1,time do
- ran = RAN(1,4)
- if ran == 1 then
- x = inc
- z = 0
- elseif ran == 2 then
- x = -inc
- z = 0
- elseif ran == 3 then
- x = 0
- z = inc
- elseif ran == 4 then
- x = 0
- z = -inc
- end
- p.CFrame = p.CFrame*CF(x,0,z)
- wait()
- end
- end)
- end
- local spark360 = function(origin, time, inc, col, HARMLESS)
- local p = part(FOL, true, time, VT(1,1,1), nil, origin.Position, "Neon", 1, 0, true, false, nil)
- if not HARMLESS then
- virtualize(false, p)
- end
- 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)
- spawn(function()
- for i = 1,time do
- ran = RAN(1,6)
- if ran == 1 then
- x = inc
- y = 0
- z = 0
- elseif ran == 2 then
- x = -inc
- y = 0
- z = 0
- elseif ran == 3 then
- x = 0
- y = 0
- z = inc
- elseif ran == 4 then
- x = 0
- y = 0
- z = -inc
- elseif ran == 5 then
- x = 0
- y = inc
- z = 0
- elseif ran == 6 then
- x = 0
- y = -inc
- z = 0
- end
- p.CFrame = p.CFrame*CF(x,y,z)
- wait()
- end
- end)
- end
- local swait = function(amount)
- if amount then
- for i = 1, amount do
- game:GetService("RunService").Stepped:Wait()
- end
- else
- game:GetService("RunService").Stepped:Wait()
- end
- end
- -----------------------------------------------------------------------Race-only functions
- local finishGlitch = function(item, text, col, size)
- spawn(function()
- for i = 1, 50 do
- spark360(item.CFrame, 50, size, col, true)
- spark360(item.CFrame, 50, size*1.5, col, true)
- end
- end)
- end
- local finishEffect = function(item, text, col, playergiven)
- hint = Instance.new("Hint")
- hint.Text = text
- hint.Parent = workspace
- game.Debris:AddItem(hint, 5)
- if not col then
- col = CSEQ(RGB(255,220,70), RGB(255,255,100))
- end
- pcall(function()
- if playergiven.Character.Head:FindFirstChild("WinnerEgo") then return end
- local bv = Instance.new("BodyVelocity")
- bv.Velocity = Vector3.new(math.random(-700, 700), math.random(1000, 2000), math.random(-700, 700))
- bv.MaxForce = Vector3.new(1e9, 1e9, 1e9)
- bv.Name = "WinnerEgo"
- bv.Parent = playergiven.Character.Head
- game.Debris:AddItem(bv, 0.2)
- end)
- spawn(function()
- for i = 1, 100 do
- local p = Instance.new("SpawnLocation")
- p.Neutral = false
- p.Anchored = false
- p.Size = Vector3.new(10, 10, 10)
- p.Position = item.Position
- p.Transparency = 0
- p.Material = "Neon"
- p.Color = item.Color
- p.Parent = FOL
- game.Debris:AddItem(p, 20)
- 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)
- local bv = Instance.new("BodyVelocity")
- bv.Velocity = Vector3.new(math.random(-1000, 1000), math.random(700, 2000), math.random(-1000, 1000))
- bv.MaxForce = Vector3.new(1e9, 1e9, 1e9)
- bv.Name = "WinnerVel"
- bv.Parent = p
- game.Debris:AddItem(bv, 0.2)
- end
- end)
- end
- local enemy = function(enemyType, place, size, special)
- local p = Instance.new("SpawnLocation")
- p.Material = "Neon"
- p.Neutral = false
- p.Massless = true
- p.Anchored = false
- p.CanCollide = false
- p.Position = place + Vector3.new(0, 1000, 0)
- p.Transparency = 0
- p.Size = Vector3.new(size, size, size)
- local pf = p:Clone()
- pf.Material = "ForceField"
- pf.Color = Color3.new(1, 0, 0)
- pf.Name = "EnemyAura"
- pf.Transparency = 0.3
- pf.Size = p.Size + (Vector3.new(0.2, 0.2, 0.2)*size)
- local weld = Instance.new("Weld")
- weld.Part0 = p
- weld.Part1 = pf
- weld.C0 = CFrame.new(0,0,0)
- weld.Parent = pf
- pf.Parent = p
- local bp = Instance.new("BodyPosition")
- bp.Position = place
- bp.Name = "BP"
- bp.Parent = p
- bp.MaxForce = Vector3.new(1e9, 1e9, 1e9)
- local originP = Instance.new("Vector3Value")
- originP.Value = place
- originP.Name = "OriginalPlace"
- originP.Parent = p
- local spin = Instance.new("BodyAngularVelocity")
- spin.AngularVelocity = Vector3.new(math.random(-10,10)/10, math.random(-10,10)/10, math.random(-10,10)/10)
- spin.MaxTorque = Vector3.new(1e9, 1e9, 1e9)
- spin.Parent = p
- spin.Name = "BV"
- if enemyType == "fling ghost" then
- p.Color = Color3.new(0.3, 0, 0)
- if special ~= nil then
- indicate(p, special.Color, special.Text, 1.25)
- pf.Color = special.Color
- p.Color = Color3.new(0, 0, 0)
- else
- indicate(p, Color3.new(1, 0, 0), "!", 1.25)
- end
- local pos = nil
- p.Touched:Connect(function(h)
- if (not h:IsDescendantOf(script)) and (h ~= workspace.Base) and (h ~= pf) then
- p.Parent = nil
- pos = p.Position
- local p2 = Instance.new("SpawnLocation")
- p2.Material = "Neon"
- p2.Neutral = false
- p2.Massless = true
- p2.Position = pos
- p2.Anchored = true
- p2.CanCollide = false
- p2.Transparency = 0
- p2.CastShadow = false
- p2.Size = Vector3.new(size, size, size)*10
- if special ~= nil then
- p2.Color = pf.Color
- else
- p2.Color = p.Color
- end
- p2.Shape = "Ball"
- spawn(function()
- for i = 1, 10 do
- p2.Transparency = i/10
- swait()
- end
- p2:Remove()
- wait(3)
- p.Parent = script
- end)
- effected = {}
- for _, player in pairs(participants) do
- dist = player:DistanceFromCharacter(p2.Position)
- if dist <= size*10*2 and not effected[player.Name] then
- effected[player.Name] = true
- bv = Instance.new("BodyVelocity")
- bv.Velocity = Vector3.new(math.random(-1000, 1000), math.random(0, 200), math.random(-1000, 1000))
- bv.MaxForce = Vector3.new(1e9, 1e9, 1e9)
- pcall(function()
- bv.Parent = player.Character.Head
- end)
- Repped:FireClient(player, "SFX", {ID = 6817150074, Loudness = 0.5})
- game.Debris:AddItem(bv, 0.2)
- end
- end
- p2.Parent = script
- end
- end)
- elseif enemyType == "powerup_random" then
- p.Color = Color3.new(1, 1, 1)
- pf.Color = Color3.new(0, 1, 0.5)
- local textthing = indicate(p, Color3.new(0, 1, 0.5), "?", 1.25)
- table.insert(colorChanging, pf)
- table.insert(colorChanging, textthing)
- local pos = nil
- p.Touched:Connect(function(h)
- if (not h:IsDescendantOf(script)) and (h ~= workspace.Base) and (h ~= pf) then
- p.Parent = nil
- pos = p.Position
- local p2 = Instance.new("SpawnLocation")
- p2.Material = "Neon"
- p2.Neutral = false
- p2.Massless = true
- p2.Position = pos
- p2.Anchored = true
- p2.CastShadow = false
- p2.CanCollide = false
- p2.Transparency = 0
- p2.Size = Vector3.new(size, size, size)*10
- p2.Color = p.Color
- p2.Shape = "Ball"
- spawn(function()
- for i = 1, 10 do
- p2.Transparency = i/10
- swait()
- end
- p2:Remove()
- wait(3)
- p.Parent = script
- end)
- effected = {}
- for _, player in pairs(participants) do
- dist = player:DistanceFromCharacter(p2.Position)
- if dist <= size*10*2 and not effected[player.Name] then
- effected[player.Name] = true
- bv = Instance.new("BodyVelocity")
- bv.Velocity = Vector3.new(math.random(-1000, 1000), math.random(0, 200), math.random(-1000, 1000))
- bv.MaxForce = Vector3.new(1e9, 1e9, 1e9)
- pcall(function()
- bv.Parent = player.Character.Head
- end)
- Repped:FireClient(player, "SFX", {ID = 6817150074, Loudness = 0.5})
- game.Debris:AddItem(bv, 0.2)
- end
- end
- p2.Parent = script
- end
- end)
- end
- p.Parent = enemyFol
- return p
- end
- local obstacle = function(obstacleType, CFplace, size)
- local p
- if obstacleType == "yeetLevel1" then
- p = Instance.new("WedgePart")
- p.Color = Color3.new(0.25, 0.1, 1)
- p.Size = Vector3.new(size*4, 10, size+5)
- elseif obstacleType == "yeetLevel2" then
- p = Instance.new("WedgePart")
- p.Color = Color3.new(0.1, 0.25, 1)
- p.Size = Vector3.new(size*4, 25, size+30)
- elseif obstacleType == "yeetLevel3" then
- p = Instance.new("WedgePart")
- p.Color = Color3.new(0.1, 1, 1)
- p.Size = Vector3.new(size*4, 40, size+70)
- else
- p = Instance.new("Part")
- p.Size = Vector3.new(size, size, size)
- end
- p.Material = "Glass"
- p.Massless = true
- p.Anchored = true
- p.CanCollide = true
- p.Transparency = 0
- p.CFrame = CFplace
- local physProperties = PhysicalProperties.new(Enum.Material.Ice)
- p.CustomPhysicalProperties = physProperties
- p.Parent = obstacleFol
- return p
- end
- for _,v in pairs(workspace:GetDescendants()) do
- if v:FindFirstChild("lastpart") then
- las = v
- end
- end
- function NEWPATH(length)
- obstacleFol.Parent = nil
- enemyFol.Parent = nil
- FOL.Parent = nil
- script:ClearAllChildren()
- obstacleFol:ClearAllChildren()
- enemyFol:ClearAllChildren()
- FOL:ClearAllChildren()
- obstacleFol.Parent = script
- enemyFol.Parent = script
- FOL.Parent = script
- path = Instance.new("SpawnLocation")
- path.Neutral = false
- path.Size = Vector3.new(500, 10, 700)
- path.Material = themes[theme]["RoadMaterial"]
- path.Color = themes[theme]["RoadColor"]
- path.Anchored = true
- path.Position = Vector3.new(0,1000,1000)
- new = {}
- participants = {}
- READYSETGO = "READY"
- raceline = Instance.new("SpawnLocation")
- raceline.Neutral = false
- raceline.Size = Vector3.new(500, 11, 20)
- raceline.Material = "Neon"
- raceline.BrickColor = BrickColor.new("Daisy orange")
- raceline.Anchored = true
- raceline.Position = Vector3.new(0,1000,900)
- raceline.CastShadow = false
- blockingwall = Instance.new("SpawnLocation")
- blockingwall.Neutral = false
- blockingwall.Size = Vector3.new(700, 700, 20)
- blockingwall.Material = "Neon"
- blockingwall.BrickColor = BrickColor.new("Persimmon")
- blockingwall.Anchored = true
- blockingwall.Position = Vector3.new(0,1000,920)
- blockingwall.Transparency = 0.75
- blockingwall.CastShadow = false
- raceline.Parent = script
- blockingwall.Parent = script
- connectedLine = raceline.Touched:Connect(function(h)
- 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
- if h.Parent:FindFirstChild("Participating") then
- return
- else
- participating = Instance.new("BoolValue", h.Parent)
- participating.Name = "Participating"
- 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
- name = game.Players:GetPlayerFromCharacter(h.Parent).Name
- participants[name] = game.Players:FindFirstChild(name)
- pcall(function()
- game.Players:GetPlayerFromCharacter(h.Parent).PlayerGui:FindFirstChild("RacingUI"):Remove()
- end)
- local newUi = ui:Clone()
- newUi.Parent = game.Players:FindFirstChild(name).PlayerGui
- NLS(UiNLS, newUi)
- end
- print("New Participant: "..game.Players:GetPlayerFromCharacter(h.Parent).Name)
- end
- local name = game.Players:GetPlayerFromCharacter(h.Parent).Name
- participants[name] = game.Players:GetPlayerFromCharacter(h.Parent)
- Repped:FireClient(participants[name], "maptype", {
- Custom = themes[theme].Cust.Start,
- Track = themes[theme].Cust.Name,
- CustomEnd = themes[theme].Cust.End})
- end
- end)
- spawn(function()
- repeat
- if READYSETGO == "SET" then
- blockingwall.BrickColor = BrickColor.new("Neon orange")
- end
- wait()
- until READYSETGO == "GO"
- blockingwall.BrickColor = BrickColor.new("Lime green")
- blockingwall.CanCollide = false
- connectedLine:Disconnect()
- end)
- path.Parent = script
- pathWall = Instance.new("SpawnLocation")
- pathWall.Neutral = false
- pathWall.Size = Vector3.new(100,500,700)
- pathWall.Material = themes[theme]["WallMaterial"]
- pathWall.Color = themes[theme]["WallColor"]
- pathWall.Position = path.Position + Vector3.new(270,0,0)
- pathWall.Anchored = true
- pathWall.Parent = script
- pathWall2 = Instance.new("SpawnLocation")
- pathWall2.Neutral = false
- pathWall2.Size = Vector3.new(100,500,700)
- pathWall2.Material = themes[theme]["WallMaterial"]
- pathWall2.Color = themes[theme]["WallColor"]
- pathWall2.Position = path.Position + Vector3.new(-270,0,0)
- pathWall2.Anchored = true
- pathWall2.Parent = script
- local lastp = nil
- if not las then
- lastp = Instance.new("BoolValue")
- lastp.Name = "lastpart"
- else
- lastp = las.lastpart
- end
- local lastpart = path
- local loadingtick = tick()
- for i = 1,length do
- clone = path:Clone()
- local uptilt = math.rad(math.random(-5,5))
- local sidetilt = math.rad(math.random(-1,1)/10)
- if (path.Position.Y) < 100 then uptilt = math.rad(math.random(5,10)) end
- if tilt == "off" then uptilt = 0 sidetilt = 0 end
- clone.CFrame = lastpart.CFrame * CFrame.new(0,math.random(-2,2),500) * CFrame.Angles(sidetilt, math.rad(math.random(-5,5))*(difficulty/10), uptilt)
- clone.Parent = script
- clonew = pathWall:Clone()
- clonew.CFrame = clone.CFrame * CFrame.new(-270,200,0)
- clonew.Parent = script
- clonew2 = pathWall2:Clone()
- clonew2.CFrame = clone.CFrame * CFrame.new(270,200,0)
- clonew2.Parent = script
- 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)})
- 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)})
- themes[theme]["Extra"](clone, false)
- if math.random(1, 3) == 1 then
- 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)
- elseif math.random(1, 3) == 2 then
- local origin = clone.CFrame * CFrame.new(math.random(-100, 100), math.random(5, 7.5) + 10, math.random(-300, 300))
- local pos = nil
- spawn(function()
- for i = 1, 10 do
- if i > 5 then
- pos = origin * CFrame.new(11 * (i-5), 11, 0)
- else
- pos = origin * CFrame.new(11 * i, 0, 0)
- end
- enemy("fling ghost", pos.Position, 10)
- end
- end)
- elseif math.random(1, 3) == 3 then
- local origin = clone.CFrame * CFrame.new(math.random(-100, 100), math.random(5, 7.5) + 10, math.random(-300, 300))
- local pos = nil
- spawn(function()
- for i = 1, 20 do
- if i > 15 then
- pos = origin * CFrame.new(11 * (i-15), 33, 0)
- elseif i > 10 then
- pos = origin * CFrame.new(11 * (i-10), 22, 0)
- elseif i > 5 then
- pos = origin * CFrame.new(11 * (i-5), 11, 0)
- else
- pos = origin * CFrame.new(11 * i, 0, 0)
- end
- enemy("fling ghost", pos.Position, 10)
- end
- end)
- end
- if math.random(1, 3) == 1 then
- 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)
- end
- lastp.Parent = clone
- lastpart = clone
- if tick() - loadingtick >= 1 then
- print("Progress: Sector "..i.."/"..length)
- loadingtick = tick()
- end
- swait(spawnInterval)
- end
- local finish = Instance.new("SpawnLocation")
- finish.Neutral = false
- finish.Size = Vector3.new(700,700,700)
- finish.Material = "Neon"
- finish.Color = Color3.new(0, 1, 0.367)
- finish.CFrame = lastpart.CFrame * CFrame.new(0,0,500)
- finish.Anchored = true
- finish.Parent = script
- finish.CanCollide = false
- finish.Name = "The End"
- local end1 = Instance.new("StringValue")
- end1.Name = "Finished"
- end1.Value = ""
- end1.Parent = finish
- local end2 = Instance.new("StringValue")
- end2.Name = "Finished2"
- end2.Value = ""
- end2.Parent = finish
- local end3 = Instance.new("StringValue")
- end3.Name = "Finished3"
- end3.Value = ""
- end3.Parent = finish
- finish.Touched:Connect(function(h)
- 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
- name = game.Players:GetPlayerFromCharacter(h.Parent).Name
- if not participants[name] then return end
- if end1.Value ~= "" then
- if end2.Value ~= "" then
- if end3.Value ~= "" then
- elseif end3.Value == "" and name ~= end2.Value and name ~= end1.Value then
- end3.Value = name
- print("Winner 3: "..name)
- finish.Color = Color3.new(0.7, 0.28, 0)
- finishEffect(finish, "Its over! "..name.." takes third place!", CSEQ(RGB(255/0.7, 255/0.28, 0)), game.Players:GetPlayerFromCharacter(h.Parent))
- 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})
- end
- elseif end2.Value == "" and name ~= end1.Value then
- end2.Value = name
- print("Winner 2: "..name)
- finish.Color = Color3.new(0.5, 0.5, 0.5)
- finishEffect(finish, "Nice job! "..name.." came second!", CSEQ(RGB(255, 255, 255)), game.Players:GetPlayerFromCharacter(h.Parent))
- 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})
- end
- else
- end1.Value = name
- print("Winner 1: "..name)
- finish.Color = Color3.new(1, 0.7, 0.3)
- finishEffect(finish, "YES! "..name.." takes first place!", nil, game.Players:GetPlayerFromCharacter(h.Parent))
- 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})
- end
- end
- end)
- print("Path finished")
- end
- ------------------------------------------------------Sound and Theme extra
- function updsound(override)
- Repped:FireAllClients("music", {CMD = override})
- end
- themes = {
- normal = {RoadColor = Color3.new(0.3,0.3,0.3),
- RoadColor2 = Color3.new(0.2,0.2,0.45),
- WallColor = Color3.new(1,1,0.7),
- WallColor2 = Color3.new(1,1,0.7),
- RoadMaterial = "Slate",
- RoadMaterial2 = "Cobblestone",
- WallMaterial = "Sand",
- WallMaterial2 = "Sand",
- Extra = function(currentPath)
- end,
- Cust = {Start = '<font face="Arcade"><font color="rgb(255,165,0)">',
- End = '</font></font>',
- Name = "Rogue Roadways"}},
- grass = {RoadColor = Color3.new(0.3,0.6,0.3),
- RoadColor2 = Color3.new(0,0.3,0.1),
- WallColor = Color3.new(0.4,0.5,0.4),
- WallColor2 = Color3.new(0,0.5,0.2),
- RoadMaterial = "Grass",
- RoadMaterial2 = "Cobblestone",
- WallMaterial = "Pebble",
- WallMaterial2 = "Marble",
- Extra = function(currentPath, alt)
- if math.random(1, 5) ~= 1 then
- pathLedge = Instance.new("SpawnLocation")
- pathLedge.Neutral = false
- pathLedge.Size = Vector3.new(500, math.random(10, 30), math.random(100, 500))
- if alt == false then
- pathLedge.Material = "Pebble"
- else
- pathLedge.Material = "Marble"
- end
- if alt == false then
- pathLedge.Color = Color3.new(0.4,0.5,0.4)
- else
- pathLedge.Color = Color3.new(0,0.5,0.2)
- end
- pathLedge.Anchored = true
- chosenRandom = math.random(300, 450)
- pathLedge.CFrame = currentPath.CFrame * CFrame.new(0, chosenRandom, 0)
- pathLedge.Parent = currentPath
- specInterval = specInterval+1
- if specInterval == 10 then
- local positions = {Tree1 = {false, -200}, Tree2 = {false, -100}, Tree3 = {false, 0}, Tree4 = {false, 100}, Tree5 = {false, 200}}
- specInterval = 0
- for i = 1,3 do
- local a
- repeat a = math.random(1, 5) until positions["Tree"..a][1] == false
- positions["Tree"..a][1] = true
- tree = Instance.new("SpawnLocation")
- tree.Neutral = false
- tree.Size = Vector3.new(math.random(50, 70), chosenRandom-1, math.random(50, 70))
- tree.Color = BrickColor.new("Burnt Sienna").Color
- tree.Material = "Wood"
- tree.Anchored = true
- tree.CFrame = currentPath.CFrame * CFrame.new(positions["Tree"..a][2], (currentPath.Size.Y/2) + (chosenRandom/2), 0)
- tree.Parent = currentPath
- treeP2 = Instance.new("SpawnLocation")
- treeP2.Neutral = false
- treeP2.Size = Vector3.new(tree.Size.X + 5, currentPath.Size.Y + 7.5, tree.Size.Z + 5)
- treeP2.Color = BrickColor.new("Burnt Sienna").Color
- treeP2.Material = "Wood"
- treeP2.Anchored = true
- treeP2.CFrame = CFrame.new(tree.CFrame.X, currentPath.CFrame.Y, tree.CFrame.Z)
- treeP2.Orientation = Vector3.new(0, tree.Orientation.Y, 0)
- treeP2.Parent = tree
- end
- end
- end
- end,
- Cust = {Start = '<font face="Antique"><font color="rgb(0,165,0)">',
- End = '</font></font>',
- Name = "Filthy Forest"}}}
- ------------------------------------------------------------------------Host/Player/Owner interactivity
- owner.Chatted:Connect(function(c)
- local c = c
- if string.sub(c, 1, string.len(prefix)) == prefix then
- c = string.sub(c, 2):lower()
- if c == "start" then
- READYSETGO = "ON YOUR MARKS"
- Repped:FireAllClients("readyset", {Text = "-3- ON YOUR MARKS -3-", Color = Color3.new(1, 0, 0)})
- READYSETGO = "ON YOUR MARKS"
- wait(1)
- Repped:FireAllClients("readyset", {Text = "-2- GET READY -2-", Color = Color3.new(1, 0.3, 0)})
- READYSETGO = "READY"
- wait(1)
- Repped:FireAllClients("readyset", {Text = "-1- SET -1-", Color = Color3.new(1, 0.7, 0)})
- READYSETGO = "SET"
- wait(1)
- Repped:FireAllClients("go")
- READYSETGO = "GO"
- elseif string.sub(c, 1, 10) == "maketrack " then
- c = string.sub(c, 11)
- if c == "grass" then
- theme = "grass"
- NEWPATH(200)
- else
- theme = "normal"
- NEWPATH(200)
- end
- elseif string.sub(c, 1, 3) == "id " then
- soundID = string.sub(c, 4)
- Mastersound.SoundId = "rbxassetid://"..soundID
- updsound("Change Id")
- elseif string.sub(c, 1, 7) == "prefix " then
- prefix = string.sub(c, 8)
- elseif string.sub(c, 1, 5) == "diff " then
- difficulty = tonumber(string.sub(c, 6))
- elseif string.sub(c, 1, 5) == "tilt " then
- c = string.sub(c, 6)
- if c == "on" or c == "true" then
- tilt = true
- elseif c == "off" or c == "false" then
- tilt = false
- end
- elseif c == "play" then
- updsound("Play")
- elseif c == "pause" then
- updsound("Stop Playing")
- elseif c == "resume" then
- updsound("Keep Playing")
- end
- end
- end)
- print("(UI Lock must be disabled.)")
- print("(Prefix: "..prefix..")")
- print([[Command List (prefix excluded):
- maketrack - Prompts the creation of the race track. Please only run once per script, or chaos will ensue (|||_ _)
- play - Plays the current music id on every player's ui.
- pause - Pauses the current music id on every player's ui.
- resume - Resumes the current music id on every player's ui.
- id - Changes the current music id for everyone.
- start - Begins the race for everyone participating.
- prefix - Changes the prefix of the script.
- diff - Changes difficulty of the race. (1-10 suggested.)
- tilt - Turns track tilting on/off. (on/off or true/false)
- (Once the race has started, no one else can join.)
- ]])
- print("Available races: \n")
- for i,v in pairs(themes) do
- print(i.." - ("..v.Cust.Name..")")
- end
- ---------------------------------------------------------------Final WHILE loop for race
- spawn(function()
- while true do
- for i = 0,1,1/350 do
- swait()
- ShiftingColor = Color3.fromHSV(i,1,1)
- end
- end
- end)
- while true do
- new = {}
- if READYSETGO == "GO" then
- for i,v in pairs(participants) do
- if v.Character:FindFirstChild("Participating") then
- table.insert(new, {i, math.floor((v.Character.Head.Position - script["The End"].Position).Magnitude)/20})
- Repped:FireClient(v, "distance", {
- Distance = math.floor((v.Character.Head.Position - script["The End"].Position).Magnitude)/20})
- else
- v.PlayerGui.RacingUI:Remove()
- participants[i] = nil
- end
- end
- table.sort(new, function(a, b) return a[2]<b[2] end)
- Repped:FireAllClients("place", new)
- end
- for _,v in pairs(colorChanging) do
- pcall(function()
- v.Color = ShiftingColor
- end)
- pcall(function()
- v.TextStrokeColor3 = ShiftingColor
- v.TextColor3 = Color3.new(1, 1, 1)
- end)
- end
- wait()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement