Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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!

0
I'll try this as well. JaytheKing452 9 — 4y
0
omg tysmmm JaytheKing452 9 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

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

0
It just plays all the lights, I want to the trigger to be touched.. sorry if I wasn't being specific. JaytheKing452 9 — 4y

Answer this question