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

Whats wrong with this script?

Asked by 10 years ago

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

Log in to vote
1
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

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)

Ad
Log in to vote
2
Answered by
RAYAN1565 691 Moderation Voter
10 years ago

I agree with @Azarth

Answer this question