generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Need help fixing this script

Previous Thread :: Next Thread 
storyofmlg is not online. storyofmlg
Joined: 10 Feb 2016
Total Posts: 41
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
storyofmlg is not online. storyofmlg
Joined: 10 Feb 2016
Total Posts: 41
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
storyofmlg is not online. storyofmlg
Joined: 10 Feb 2016
Total Posts: 41
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 is not online. 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 is not online. 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
storyofmlg is not online. storyofmlg
Joined: 10 Feb 2016
Total Posts: 41
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
storyofmlg is not online. storyofmlg
Joined: 10 Feb 2016
Total Posts: 41
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
storyofmlg is not online. storyofmlg
Joined: 10 Feb 2016
Total Posts: 41
07 Jan 2017 02:34 PM
I really need help on fixing this. Anyone?
Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
07 Jan 2017 02:38 PM
local function = onClick()

try this
Report Abuse
storyofmlg is not online. storyofmlg
Joined: 10 Feb 2016
Total Posts: 41
07 Jan 2017 03:22 PM
... local function onClick() is already in my script. Why aren't people actually READING my posts?
Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
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
storyofmlg is not online. storyofmlg
Joined: 10 Feb 2016
Total Posts: 41
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
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
07 Jan 2017 03:29 PM
I meant this sorry

local onclick = function()
--code
end)

Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
07 Jan 2017 03:30 PM
Forgot the capital

local onClick = function()
--code
end)
Report Abuse
storyofmlg is not online. storyofmlg
Joined: 10 Feb 2016
Total Posts: 41
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
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
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
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
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
storyofmlg is not online. storyofmlg
Joined: 10 Feb 2016
Total Posts: 41
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
storyofmlg is not online. storyofmlg
Joined: 10 Feb 2016
Total Posts: 41
08 Jan 2017 08:45 AM
Bump
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image