Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

trying to make sort of a stop light system, but it won't work?

here is my code, it runs but nothing is happening and no error.

local purpleLight = game.Workspace.Model.Purple.PointLight
local yellowLight = game.Workspace.Model.Yellow.PointLight
local greenLight = game.Workspace.Model.Green.PointLight
local blueLight = game.Workspace.Model.Blue.PointLight
local Trigger = game.Workspace.Trigger

function triggert()

purpleLight.Enabled = true

wait(1)

purpleLight.Enabled = false

blueLight.Enabled = true

wait(1)

blueLight.Enabled = false

yellowLight.Enabled = true

wait (1)

yellowLight.Enabled = false

greenLight.Enabled = true

wait(1)

greenLight.Enabled = false

end

2 answers

✓ Accepted answer

I believe you are not calling the function, as well as the function command is quite outdated. This is how I would go about it, since I don't know what you want it to be triggered on, I'm using touch.

local purpleLight = game.Workspace.Model.Purple.PointLight
local yellowLight = game.Workspace.Model.Yellow.PointLight
local greenLight = game.Workspace.Model.Green.PointLight
local blueLight = game.Workspace.Model.Blue.PointLight
local Trigger = game.Workspace.Trigger

Trigger.Touched:Connect(function(hit)

if hit.Parent:FindFirstChild('Humanoid') then

	purpleLight.Enabled = true
	
	wait(1)
	
	purpleLight.Enabled = false
	
	blueLight.Enabled = true
	
	wait(1)
	
	blueLight.Enabled = false
	
	yellowLight.Enabled = true
	
	wait (1)
	
	yellowLight.Enabled = false
	
	greenLight.Enabled = true
	
	wait(1)

	greenLight.Enabled = false

	end
end)

Let me know if this works!

2 comments

0

I'll try this as well.

0

omg tysmmm

Try adding "triggert()" at the end of the script.

1 comment

0

It just plays all the lights, I want to the trigger to be touched.. sorry if I wasn't being specific.

This discussion is preserved as it was. New answers, comments, and votes are closed.