|
| 07 Jan 2017 12:18 PM |
I have a script inside of a button inside of a ScreenGUI which I'm using as a settings button. I already have the button, the settings gui, etc. all set up, but it doesn't open the settings GUI when I click the settings button. The only error I see is that there's a blue line under "player" saying that there's no global named player. Some help, please? Here is the script:
local gui = script.Parent.Parent.Parent.SettingsGUI local function onClick()
gui:Clone().Parent = player.PlayerGui end
script.Parent.MouseButton1Click:connect(onClick)
NOTE: I noticed that putting "player" inside of the parentheses and turning the second line into this fixes the blue line, but it does not open the settings still.
onClick() ---> onClick(player) |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 12:23 PM |
| Please note that I've already tried putting this in both a normal script and a local script. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 12:26 PM |
I also added another line to find the player. It still didn't work.
NEW SCRIPT
local gui = script.Parent.Parent.Parent.SettingsGUI local player = game.Players.LocalPlayer local function onClick()
gui:Clone().Parent = player.PlayerGui end
script.Parent.MouseButton1Click:connect(onClick) |
|
|
| Report Abuse |
|
|
edenDeden
|
  |
| Joined: 29 Jul 2016 |
| Total Posts: 370 |
|
|
| 07 Jan 2017 12:34 PM |
what u trying to do?i didnt understand
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 07 Jan 2017 12:37 PM |
You never actually define the player
local player = game.Players.LocalPlayer -- you need to define it somehow local gui = script.Parent.Parent.Parent.SettingsGUI -- try going top-down instead of saying .Parent 10 million times local button = script.Parent
button.MouseButton1Click:connect(function() gui:Clone().Parent = player.PlayerGui -- why are we cloning it? Don't we just want to make the settings page visible? How are we going to actually save the settings? How are we going to get rid of this gui? end)
|
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 12:40 PM |
| Please actually read everything I wrote. I said I already defined the player, and it didn't work. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 12:41 PM |
| Also, I pasted your script in and fixed names and whatever I needed to fix, and it didn't work. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 02:34 PM |
| I really need help on fixing this. Anyone? |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 02:38 PM |
local function = onClick()
try this |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 03:22 PM |
| ... local function onClick() is already in my script. Why aren't people actually READING my posts? |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 03:24 PM |
The "=" sign is the difference... Read the post fully lmao
And you tell others to read yours |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 03:25 PM |
| Sorry, I didn't see you added the = in there. Although, an equals sign doesn't belong there. It just gives you an error if you put it there. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 03:29 PM |
I meant this sorry
local onclick = function() --code end)
|
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 03:30 PM |
Forgot the capital
local onClick = function() --code end) |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 03:30 PM |
| Nope. I honestly don't get why this isn't working, all the code is valid and there's no errors. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 03:33 PM |
local gui = script.Parent.Parent.Parent.SettingsGUI local onClick = function() print("running") gui:Clone().Parent = player.PlayerGui end
script.Parent.MouseButton1Click:connect(onClick)
Try this and reply if it prints running |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 03:40 PM |
local Plr = game.Players.LocalPlayer local PGui = Plr.PlayerGui
script.Parent.MouseButton1Click:connect(function() local gui = script.Parent.Parent.Parent.SettingsGUI:Clone() gui.Parent = PGui end)
If that doesn't work, then recheck your gui. You may have the Visible property set to false. |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2017 04:08 PM |
xiaoxiao181 script works... although, there's still an issue. Here, I'll explain: The SettingsGUI is currently in the starter gui, so it's visible by default when I start the game. If I press the X button to close that GUI and try to reopen it, it doesn't work. Although, if I open Settings again WHILE the first one is already open, it works. Basically what I'm saying is, it only opens the GUI if the original GUI is already visible.
This is because the X button "removes" that original GUI, and there's nothing to clone. The script in the X button removes the GUI so it disappears. How do I hide the GUI without removing it? |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Jan 2017 01:56 PM |
| Well then where's the rest of the script? There's clearly an issue with pathing in whatever script you're using to open and close the interface |
|
|
| Report Abuse |
|
|