|
| 26 Dec 2013 06:58 PM |
Ok I made this script to have an inventory apear. So in StarterGui I have a Gui with a frame and text Button. the txt button includes the script below. However when I go to test it I turn my Frame to invisible and I go to start server start player and it doesn't work.
function Click(hi) frame = script.Parent.Parent:FindFirstChild("Frame") if frame ~= nil then frame.Visible = false else Print ('WTF') end end script.Parent.Clicked:connect(Click)
Thank you kind person. |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 26 Dec 2013 07:01 PM |
script.Parent.MouseButton1Down:connect(function(hi) frame = script.Parent.Parent:FindFirstChild("Frame") if frame ~= nil then frame.Visible = false else Print("WTF") end end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Dec 2013 07:03 PM |
So, what I'm understanding is you want an inventory to appear when a button is clicked? If so, read further. You must define the clicking function this way: function Click() -- You do not put what is clicked in parentheses. You must use MouseClick1Down to define the clicking function.. |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 26 Dec 2013 07:05 PM |
| Are you sure you defined "Frame" as it should be? Is the actual frame called Frame? |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2013 07:05 PM |
function Click() script.Parent.MouseButton1Down:connect frame = script.Parent.Parent:FindFirstChild("Frame") if frame ~= nil then frame.Visible = false else Print("WTF") end end -- This should be correct. |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 26 Dec 2013 07:06 PM |
| ^ Dude, you forgot (function() |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2013 07:07 PM |
Whoops, I'm failing today. Kinda tired, don't use that one, it probably will error.
|
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 26 Dec 2013 07:09 PM |
| Mine should work perfectly fine unless he didn't located the Frame correctly. |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2013 07:10 PM |
| Yeah, assuming he didn't, he needs to do that. |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2013 07:10 PM |
It didn't work. function onClick(hi) frame = game.StarterGui.HeroMorphs.Frame.Visible if frame == false then frame = true end end script.Parent.MouseClick1Down:connect(onClick) |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 26 Dec 2013 07:11 PM |
| lol the if statement isn't useful |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
| |
|
| |
|
|
| 26 Dec 2013 07:12 PM |
@above I'm assuming he has no idea how clicking functions work.. |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Dec 2013 07:13 PM |
| Yeah I'm a bad script an a good builder who doesn't want to use free m0dels but is about to D: |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 26 Dec 2013 07:13 PM |
| actually vespero when you said @2 about you meant three. |
|
|
| Report Abuse |
|
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 26 Dec 2013 07:13 PM |
Dude, if you edit StarterGui it won't work...
Try this, and put it into a Local Script:
player = game.Players.LocalPlayer
script.Parent.MouseButton1Down:connect(function() frame = player.PlayerGui.HeroMorphs.Frame if frame.Visible = false then frame.Visible = true else print("Your argument is invalid!") end end) |
|
|
| Report Abuse |
|
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 26 Dec 2013 07:15 PM |
here
sp = script.Parent frame = game.StarterGui.HeroMorphs:findFirstChild("Frame")
sp.MouseButton1Clicked:connect(function() frame.Visible = not frame.Visible --it's a toggle (i think thats what you want end)
|
|
|
| Report Abuse |
|
|
| |
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 26 Dec 2013 07:18 PM |
oops
Put this in a localscript
sp = script.Parent frame = game.Player.LocalPlayer.PlayerGui.HeroMorphs:findFirstChild("Frame")
sp.MouseButton1Clicked:connect(function() frame.Visible = not frame.Visible --it's a toggle (i think thats what you want end) |
|
|
| Report Abuse |
|
|