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

Whats wrong with this script?

Hi, I've been making a Play Game Gui for my games and it doesn't disappear when i click it.

Player = game.Players.Localplayer
Menu = script.Parent
Play = Menu.Play
About = Menu.About
HasPressedPlay = False 

function MouseEnterPlayerButton()
	Play.FontSize = "Size36"
	Play.BackGroundColor3 = Color3.new(0.54, 0.62, 0.7)
	Play.Size = UDim2.new(0.45, 0, 0.225, 0)
end

function MouseLeftPlayButton()
	--135, 161, 170
	Play.FontSize = "Size24" 
	Play.Size = UDim2.new(0.3, 0, 0.15, 0)  
end

function PlayGame()
	if HasPressedPlay == false then
		for GuiMove = 1, 30 do
			if Guimove <= 20 then
			Play.Position = Udim2.new(0.05, 0, 0, 0)
			
				
			end
			wait()
	    end		
	Menu:remove()
	end
end

Play.MouseLeave:connect(MouseLeftPlayButton)
Play.MouseEnter:connect(MouseEnterPlayButton)
Play.MouseButton1Down:connect(PlayGame)

2 answers

✓ Accepted answer

You spelled UDim2 wrong, but I'd suggest Tweening it as well.

Player = game.Players.Localplayer
Menu = script.Parent
Play = Menu.Play
About = Menu.About
HasPressedPlay = false 

function MouseEnterPlayerButton()
    Play.FontSize = "Size36"
    Play.BackGroundColor3 = Color3.new(0.54, 0.62, 0.7)
    Play.Size = UDim2.new(0.45, 0, 0.225, 0)
end

function MouseLeftPlayButton()
    --135, 161, 170
    Play.FontSize = "Size24" 
    Play.Size = UDim2.new(0.3, 0, 0.15, 0)  
end

function PlayGame()
    if HasPressedPlay == false then
	HasPressedPlay = true
	Play:TweenPosition(UDim2.new(0.05, 0, 0, 0), "Out","Quad",  .5, true)
	wait(.5)
	Menu:Destroy()
	-- remove is deprecated
    end
end

Play.MouseLeave:connect(MouseLeftPlayButton)
Play.MouseEnter:connect(MouseEnterPlayButton)
Play.MouseButton1Down:connect(PlayGame)

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