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

Value and transparency changes for signal?

Asked by 3 years ago

I'm creating a signal system. I've added 2 Boolvalues into the signal. One called "red" and another one "green". I want a red light to appear(red cylinder) when the Boolvalue "red" is true. And then when the "green" is true I want a green light to appear and make the red light disappear. This is the script I have in the signal I want to change

red = script.Parent.red
green = script.Parent.green

if red.Value == true then
    script.Parent.Red.Transparency = 0
    script.Parent.Green.Transparency = 1
    script.Parent.Yellow3.Transparency = 1
    script.Parent.Yellow2.Transparency = 1
    script.Parent.Yellow1.Transparency = 1
    green.Value = false
else
    red.Value = false
    script.Parent.Red.Transparency = 1
    script.Parent.Green.Transparency = 0
    script.Parent.Yellow3.Transparency = 1
    script.Parent.Yellow2.Transparency = 1
    script.Parent.Yellow1.Transparency = 1
end

The way I tried it out is with a junction with the script

Check = script.Parent.Check

script.Parent.Changer.ClickDetector.MouseClick:Connect(function()
    if Check.Value == true then
        script.Parent.Changer.Transparency = 0.5
        script.Parent.Left1.Track110.track1.CanCollide = true
        script.Parent.Left1.Track110.track2.CanCollide = true
        script.Parent.Left2.Track110.Track1.CanCollide = true
        script.Parent.Left2.Track110.Track2.CanCollide = true
        script.Parent.Left3.Track110.track1.CanCollide = true
        script.Parent.Left3.Track110.track2.CanCollide = true
        script.Parent.Left4.Track110.track1.CanCollide = true
        script.Parent.Left4.Track110.track2.CanCollide = true
        script.Parent.Right1.Track110.track1.CanCollide = false
        script.Parent.Right1.Track110.track2.CanCollide = false
        game.Workspace.PUsignalspor1taulovmodKolding.Model.PUTEST.red.Value = false
        game.Workspace.PUsignalspor1taulovmodKolding.Model.PUTEST.green.Value = true

        Check.Value = false
    else
        script.Parent.Changer.Transparency = 0
        script.Parent.Left1.Track110.track1.CanCollide = false
        script.Parent.Left1.Track110.track2.CanCollide = false
        script.Parent.Left2.Track110.Track1.CanCollide = false
        script.Parent.Left2.Track110.Track2.CanCollide = false
        script.Parent.Left3.Track110.track1.CanCollide = false
        script.Parent.Left3.Track110.track2.CanCollide = false
        script.Parent.Left4.Track110.track1.CanCollide = false
        script.Parent.Left4.Track110.track2.CanCollide = false
        script.Parent.Right1.Track110.track1.CanCollide = true
        script.Parent.Right1.Track110.track2.CanCollide = true
        game.Workspace.PUsignalspor1taulovmodKolding.Model.PUTEST.red.Value = true
        game.Workspace.PUsignalspor1taulovmodKolding.Model.PUTEST.green.Value = false
        Check.Value = true
    end
end)

The check.value is to check if the junction is going straight(right) or left

    game.Workspace.PUsignalspor1taulovmodKolding.Model.PUTEST.red.Value = true
    game.Workspace.PUsignalspor1taulovmodKolding.Model.PUTEST.green.Value = false 

That is the script that should change the value of the signal where the signals light should've changed in the script, but it doesn't seem to work. Still new at scripting. Any help would be appreciated

1 answer

Log in to vote
1
Answered by 3 years ago

if I got into such a situation, I would write the following code:

local red = (red cylinder)
local green = (green cylinder)
red: true
if red: true then
green: false
end
local red = (red cylinder)
local green = (green cylinder)
red: false
if red: false then
green: true

but I'm not sure...

0
That doesn't really work. But I figured a way to change the red Boolvalue and the green Boolvalue. Now I just want a script to "Check" what the values are. and if the green boolvalue is true then the transparency for the green cylinder changes. Tried a bit like this with your script boysharkdk 34 — 3y
0
~~~~~~~~~~~~~~~~~ local red = script.Parent.red.Value local green = script.Parent.green.Value red = true if red == true then green = false script.Parent.Red.Transparency = 0 script.Parent.Green.Transparency = 1 script.Parent.Yellow3.Transparency = 1 script.Parent.Yellow2.Transparency = 1 script.Parent.Yellow1.Transparency = 1 end local red = script.Parent.red.Value local ~~~~~~~~~~~~~~~~~ boysharkdk 34 — 3y
0
Nvm I figured it out thanks. boysharkdk 34 — 3y
Ad

Answer this question