local RedLight = game.Workspace.StartLight.RedModel.LightBulb.PointLight
local YellowLight = game.Workspace.StartLight.YellowModel.LightBulb.PointLight
local GreenLight = game.Workspace.StartLight.GreenModel.LightBulb.PointLight
local Barrier = game.Workspace.Wall
local RaceInProgress = false
local Checkpoint4 = game.Workspace.Checkpoint4
local Checkpoint1 = game.Workspace.Checkpoint1
local Checkpoint2 = game.Workspace.Checkpoint2
local Checkpoint3 = game.Workspace.Checkpoint3
function CreateCars()
01 | for _, object in pairs (game.Workspace:GetChildren()) do |
05 | if object.Name = = "Car" then |
07 | print ( "This is a car, we need to destroy it!" ) |
end
function DestroyCars()
1 | for _, object in pairs (game.ServerStorage:GetChildren()) do |
3 | local carCopy = object:Clone() |
5 | carCopy.Parent = game.Workspace |
end
function ResetLights()
1 | RedLight.Enabled = false |
3 | YellowLight.Enabled = false |
5 | GreenLight.Enbled = false |
end
function ResetBarrier()
1 | Barrier.CanCollide = true |
3 | Barrier.Transparency = 0.5 |
end
function ResetLightCycle()
01 | RedLight.Enabled = true |
05 | RedLight.Enabled = false |
07 | YellowLight.Enabled = true |
11 | YellowLight.Enabled = false |
13 | GreenLight.Enabled = true |
end
function RemoveBarrier()
1 | Barrier.Transparency = 1 |
3 | Barrier.CanCollide = false |
end
function ShowVictoryMessage (playerName)
1 | local message = Instance.New( "Message" ) |
3 | message.Text = playerName .. " has won!" |
5 | message.Parent = game.Workspace |
end
function Checkpoint4Hit (OtherPart)
1 | print ( "Checkpoint4 was hit" ) |
5 | if OtherPart ~ = nil and OtherPart.Parent ~ = nil and OtherPart.Parent:FindFirstChild ( "Humanoid" ) then |
7 | print ( "A player hit me!" ) |
9 | if not Checkpoint 4 :FindFirstChild(OtherPart.Parent.Name) and Checkpoint 3 :FindFirstChild |
(OtherPart.Parent.Name) then
1 | local playerTag = Instance.new( "StringValue" ) |
3 | playerTag.parent = Finish |
5 | playerTag.name = OtherPart.Parent.Name |
end
Finish.Touched:connect(FinishHit)
function Checkpoint1Hit (OtherPart)
01 | print ( "Checkpoint1 was hit" ) |
05 | if OtherPart ~ = nil and OtherPart.Parent ~ = nil and OtherPart.Parent:FindFirstChild ( "Humanoid" ) then |
07 | print ( "A player hit me!" ) |
09 | if Checkpoint 1 :FindFirstChild (OtherPart.Parent.Name) then |
11 | local playerTag = Instance.new( "StringValue" ) |
13 | playerTag.parent = Checkpoint 1 |
15 | playerTag.name = OtherPart.Parent.Name |
19 | if Finish:FindFirstChild (OtherPart.Parent.Name) and RaceInProgress then |
21 | print ( "Player wins!" ) |
23 | RaceInProgress = false |
25 | ShowVictoryMessage(OtherPart.Parent.Name) |
end
Checkpoint1.Touched:connect(Checkpoint1Hit)
function Checkpoint2Hit (OtherPart)
1 | print ( "Checkpoint2 was hit" ) |
5 | if OtherPart ~ = nil and OtherPart.Parent ~ = nil and OtherPart.Parent:FindFirstChild ( "Humanoid" ) then |
7 | print ( "A player hit me!" ) |
9 | if not Checkpoint 2 :FindFirstChild(OtherPart.Parent.Name) and Checkpoint 1 :FindFirstChild |
(OtherPart.Parent.Name) then
1 | local playerTag = Instance.new( "StringValue" ) |
3 | playerTag.parent = Checkpoint 2 |
5 | playerTag.name = OtherPart.Parent.Name |
end
Checkpoint2.Touched:connect(Checkpoint2Hit)
function Checkpoint3Hit (OtherPart)
1 | print ( "Checkpoint3 was hit" ) |
5 | if OtherPart ~ = nil and OtherPart.Parent ~ = nil and OtherPart.Parent:FindFirstChild ( "Humanoid" ) then |
7 | print ( "A player hit me!" ) |
9 | if not Checkpoint 3 :FindFirstChild(OtherPart.Parent.Name) and Checkpoint 2 :FindFirstChild |
(OtherPart.Parent.Name) then
1 | local playerTag = Instance.new( "StringValue" ) |
3 | playerTag.parent = Checkpoint 3 |
5 | playerTag.name = OtherPart.Parent.Name |
end
Checkpoint3.Touched:connect(Checkpoint3Hit)
function ClearCheckpoint(Checkpoint)
1 | for _, object in pairs (Checkpoint:GetChildren()) do |
3 | if object.Name ~ = "TouchInterest" then |
end
wait(10)
while true do
09 | ClearCheckpoint(Checkpoint 1 ) |
11 | ClearCheckpoint(Checkpoint 2 ) |
13 | ClearCheckpoint(Checkpoint 3 ) |
15 | ClearCheckpoint(Checkpoint 4 ) |
25 | while RaceInProgress = = true do |
end
Please help, It would mean alot, I am almost done making my game.
Thanks.