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

My railway juniction script dosent work, what is the problem?

Asked by 2 years ago

hello my script is not working, can somebody help fix it?

local state = script.Parent.Parent.Parent.Value
local IgliA = script.Parent.Parent.Parent.iglia
local IgliB = script.Parent.Parent.Parent.iglib

function onClicked()
    if state == 0 then
       IgliA.Transparency = 0.8
       IgliB.Transparency = 0
       IgliA.CanCollide = false
       IgliB.CanCollide = true
       state = 1
    end

    if state == 1 then
        IgliA.Transparency = 0
        IgliB.Transparency = 0.8
        IgliA.CanCollide = true
        IgliB.CanCollide = false
        state = 0
    end
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
1
Your variable [[state]] has the value of what the Value is at the time you make the variable. remove .Value at the end and then add .Value in your if statements Spjureeedd 385 — 2y
1
And of course add .Value when you change the value of [[state]] Spjureeedd 385 — 2y
0
@Spjureeedd, I recommend you make that an answer and not a comment. IAmNotTheReal_MePipe 418 — 2y

1 answer

Log in to vote
-1
Answered by 2 years ago

i fixed problem by making two scripts

script a:

function onClickeda()
    script.Parent.Parent.Parent.iglia.Transparency = 0.8
    script.Parent.Parent.Parent.iglib.Transparency = 0
    script.Parent.Parent.Parent.iglia.CanCollide = false
    script.Parent.Parent.Parent.iglib.CanCollide = true
end
script.Parent.ClickDetector.MouseClick:Connect(onClickeda)

script b:

function onClickedb()
    script.Parent.Parent.Parent.iglia.Transparency = 0
    script.Parent.Parent.Parent.iglib.Transparency = 0.8
    script.Parent.Parent.Parent.iglia.CanCollide = true
    script.Parent.Parent.Parent.iglib.CanCollide = false
end
script.Parent.ClickDetector.RightMouseClick:Connect(onClickedb)
Ad

Answer this question