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

Why does this button get clicked when I don't click it?

local currentgame = script.Parent.Parent.Parent
local menu = script.Parent
local play = script.Parent.Play
local quit = script.Parent.Quit
local upgrades = script.Parent.Upgrades
local quitmenu = script.Parent.Parent.Quit
local upgradesmenu = script.Parent.Parent.Upgrades
local gamemenu = script.Parent.Parent.Game

if currentgame.Visible == true then
	if play.MouseButton1Down then
		gamemenu.Visible = true
		menu.Visible = false
		print 'clicked play'
	end	
end

When I load my game, it prints "clicked play" in the output and loads the "gamemenu" screen, and I never even clicked the button? Help would be very much appreciated!

1 answer

✓ Accepted answer

This is because MouseButton1Down is not a boolean. A working way to do this would be to use MouseButton1Down as an event, because that's what it is.

currentgame = script.Parent.Parent.Parent -- all these don't need to be local, unless they are in a function or anf if statement or a loop.
menu = script.Parent
play = script.Parent.Play
quit = script.Parent.Quit
upgrades = script.Parent.Upgrades
quitmenu = script.Parent.Parent.Quit
upgradesmenu = script.Parent.Parent.Upgrades
gamemenu = script.Parent.Parent.Game

play.MouseButton1Down:connect(function()--eventy
	if currentgame.Visible then--no need for == true
		gamemenu.Visible = true
        menu.Visible = false
        print 'clicked play'--this stuff
	end
end)

I hope i helped!

2 comments

0

Oh of course! I am dumb, learned a few things though, thanks!!!! :D

0

Happy to help!

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