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

My play button on my menu gui dosen't work???

Asked by 8 years ago
function on(click)
    if localplayer.click = true then
        Wait(0.1)
        local player.Script.Parent:remove()
    end
end

That's the script what's wrong with this script?

4 answers

Log in to vote
1
Answered by
Kryddan 261 Moderation Voter
8 years ago

First of all, you're missing another equal sign in your if statement.
if localplayer.click == true then

It should be like that be because when you're giving a variable a value then you use one single equal sign, but in this case, if you want to check if a variable is true then you use double equal signs ==. You can also use:

= -- define variable to a value
== -- equals to
< -- less than
> -- greater than
~= -- not equal to
<= -- less or equal to
>= -- greater or equal to

The click variable doesn't do anything at this point and there is a much easier way to check if the player clicked a button. MouseButton1Click does this for you, set it up like this: Gui.MouseButton1Click:connect(function() The "Gui" you will change to the location of your gui you want to check if you clicked on. MouseButton1Click is the method we use and :connect(function() is nothing that I can explain very well but you can read more about it here: http://wiki.roblox.com/index.php?title=Anonymous_function, basically it's a start of a function. You can also use this methods:

MouseButton1Click --fires when your left mouse button is fully clicked, down then up
MouseButton1Down --this fires when the left mouse button is pushed down
MouseButton1Up -- this fires when the left mouse button is released
MouseButton2Click
MouseButton2Down
MouseButton2Up --this is the same as the others but with the mouse button to the right instead

local player.Script.Parent:remove() Okey, all you did was creating a new variable that doesn't have any value. I do assume you meant to write localplayer.Script.Parent:remove(). I do assume that this is in a local script inside the Gui and that localplayer is already defined, if not define localplayer in the beginning of the script like this: local localplayer = game.Players.LocalPlayer, this will only work in local scripts. The player gui should be in PlayerGui and you can access that by localplayer.PlayerGui, but it won't be needed in this case because all we can do is script.Parent and we access the gui.

Also removing the gui is that actually what you want to do? Isn't it just much better to make it invisible by using the visible property inside gui's script.Parent.Visible = false, if "Visible" is false then the gui becomes invisible and if I am not mistaken, non-interactive.

So the script should look something like this:

local localplayer = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
    wait(.1)
    script.Parent.Visible = false --script should be uncapitalised
end)
Ad
Log in to vote
0
Answered by 8 years ago
player.Script.Parent:Destroy()

Try that

0
Didn't work StarInTheSkys 0 — 8y
Log in to vote
0
Answered by 8 years ago

Anyone have another script for a play menu button? :(

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Try this script, it is extremely simple and easy:

****local function OnClick() script.Parent.Parent:Remove() end

script.Parent.MouseButton1Click:connect(OnClick)****

First, make a ScreenGui in the StarterGui. Then, add a Frame to the ScreenGui. Customize the Frame however you like. After that, add a TextButton into the Frame. Again, customize the TextButton however you like. Add a Script into the TextButton, and copy the script from above into it.

(Apologies. The script above is not saving in the order it was supposed to be. To put it back to the correct order, do this:

'local function OnClick()' should be the first line. Highlight the rest of the line ('script.Parent.Parent:Remove() end') and move it to the line underneath. Then, move 'end' to the line underneath THAT. 'script.Parent.MouseButton1Click:connect(OnClick)' should be a paragraph apart from the word 'end'. Once you put that into the script, highlight it, then press 'Play' just to make sure it works. If you do not see the script in the incorrect order, ignore this.)

Answer this question