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

Please help with this please?

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!

1 comment

2

add a wait(1) after Line 1. You made an infinite loop which will crash the player.

2 answers

✓ Accepted answer
  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)

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

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