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

Script won't trigger?

Asked by 10 years ago

The script is supposed to disable GUI1 when brick ''checkpoint1'' has a transparency of 1, which makes it invisible.

code:

script.Parent.GUI1

if game.Workspace.checkpoint1.Transparency = 1 then

script.Parent.GUI1.Visible = false

Why won't it do so?

this is in a local script in GUI.

1 answer

Log in to vote
0
Answered by
Minifig77 190
10 years ago

You don't have any event listeners inside of your code. When the game first runs, it'll go through your code and see the if, and say "okay, is checkpoint1 transparent?" Then, it'll see that it's not and pass on by. Then, if it does become transparent, it won't notice, because it's not checking. What you have to do is attach an event listener to the code like so:

game.Workspace.checkpoint1.Changed:connect(function() --This is an event listener, it triggers a function.
    if game.Workspace.checkpoint1.Transparency == 1 then
        script.Parent.GUI1.Visible = false
    end
end)

Some other errors I saw in your code:

  1. What's the purpose of line 1? It's not doing anything.

  2. Whenever you're checking values in if statements, you use two equal signs (==) Because: = means equals (in other words, you're setting the value) == means is equal to (in other words, you're checking if this is equal to that.)

  3. You need to have an end on that if statement.

Ad

Answer this question