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

Please help with this please?

Asked by 10 years ago

This is a huge problem for me and I tried multiple scripts and nothing is working. I'm hoping to find a answer here.

while true do
base = game.Workspace.Items
change = script.Parent
base.NightVision.Changed:connect(function()
    if base.NightVision.Value == true then
           change.Visible = true
    end
end)

while true do is for constantly looking to see if the value is true and if it is, the button is visible Thanks!

2
add a wait(1) after Line 1. You made an infinite loop which will crash the player. ultimate055 150 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

1) You were missing an end for the while loop

2)The while loop is not needed because the event is fired whenever the value is changed.

base = game.Workspace.Items
change = script.Parent
base.NightVision.Changed:connect(function()
    if base.NightVision.Value then
           change.Visible = true
    end
end)
Ad
Log in to vote
1
Answered by 10 years ago

No need for a loop. You can just use your Changed event to check when the Value has changed:

base = game.Workspace.Items
change = script.Parent
base.NightVision.Changed:connect(function(val)
    if val == true then
        change.Visible = true
    end
end)

See how I used base.NightVision.Changed:connect(function(val) I put val in so instead of writing base.NightVision.Value you can use **val ** as the value in the function. Is the same as the base.NightVision.Value, just made to be a little simpler to use.

Hope this helped and remember to +1 and accept answer for others who are stuck with this problem.

  • NinjoOnline

Answer this question