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

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

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)

3 comments

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

1

And of course add .Value when you change the value of [[state]]

0

@Spjureeedd, I recommend you make that an answer and not a comment.

1 answer

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)

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