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: GUI Part

Previous Thread :: Next Thread 
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
28 Jun 2016 10:28 PM
I'm using this script to open up a GUI when you touch a specific part:

local Gui = game.Workspace.GuiPart

function GiveGui(Player)
if Player.PlayerGui:FindFirstChild(Gui.Name)~=nil then return end
Gui:Clone().Parent=Player.PlayerGui
end

script.Parent.Touched:connect(function(hit)

local Player=game.Players:GetPlayerFromCharacter(hit.Parent)
if Player==nil then return end
GiveGui(Player)

end)


But then, how would I make it so that when you're not touching the part anymore, the gui disables/goes away?
Report Abuse
Fribet is not online. Fribet
Joined: 08 Feb 2014
Total Posts: 700
28 Jun 2016 10:33 PM
Check out this API http://wiki.roblox.com/index.php?title=API:Class/BasePart/TouchEnded


Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
28 Jun 2016 10:42 PM
I'm sorry, I got some kind of "Certificate error" when I clicked your link :<
Report Abuse
Shiro75 is not online. Shiro75
Joined: 18 Jan 2010
Total Posts: 587
28 Jun 2016 10:46 PM
Here's an example from that website:

Workspace.Part.TouchEnded:connect(function(otherPart)
print(otherPart)
end)
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
28 Jun 2016 10:51 PM
wiki.roblox.com/index.php?title=API:Class/BasePart/TouchEnded


Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
28 Jun 2016 11:01 PM
Ah, I'm not doing something right.

local Gui = game.Workspace.GuiPart

function GiveGui(Player)
if Player.PlayerGui:FindFirstChild(Gui.Name)~=nil then return end
Gui:Clone().Parent=Player.PlayerGui
end

script.Parent.Touched:connect(function(hit)
script.Parent.TouchEnded:connect(function(hit)

local Player=game.Players:GetPlayerFromCharacter(hit.Parent)
if Player==nil then return end
GiveGui(Player)

end)


^^^ Doesn't work.
Report Abuse
Shiro75 is not online. Shiro75
Joined: 18 Jan 2010
Total Posts: 587
28 Jun 2016 11:14 PM
What happened to this part?

script.Parent.Touched:connect(function(hit)

local Player=game.Players:GetPlayerFromCharacter(hit.Parent)
if Player==nil then return end
GiveGui(Player)

end)


Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
28 Jun 2016 11:30 PM
What I basically did is I added

script.Parent.TouchEnded:connect(function(hit)

under the script.Parent.Touched:connect(function(hit) part. I don't understand how to add that line in properly so it works
Report Abuse
Shiro75 is not online. Shiro75
Joined: 18 Jan 2010
Total Posts: 587
29 Jun 2016 12:27 AM
Are you trying to make the same thing happen after you touch and untouch the part? That's how it is set up right now.
Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
29 Jun 2016 12:52 AM
Yep! Just making the GUI appear when you touch the part, then making it go away when you're not touching the part.
Report Abuse
Shiro75 is not online. Shiro75
Joined: 18 Jan 2010
Total Posts: 587
29 Jun 2016 02:28 AM
You could make a different function, perhaps TakeGui(), and instead of using :Clone(), use :Remove() after you make sure that the player has the GUI. I could write it for you, but I don't think that will help you as much.
Report Abuse
Fribet is not online. Fribet
Joined: 08 Feb 2014
Total Posts: 700
29 Jun 2016 02:03 PM
Nvm, MarketPlaceService worked, sorry for the confusion.


Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
29 Jun 2016 11:57 PM
Still stumped. This isn't working either.

local Gui = game.Workspace.GuiPart

function GiveGui(Player)
if Player.PlayerGui:FindFirstChild(Gui.Name)~=nil then return end
script.Parent.Visible = true
end

function RemoveGui(Player)
if p == game.Players.LocalPlayer.Character.Torso then
script.Parent.Visible = false

end

game.Workspace.GuiPart.Touched:connect(Open)
game.Workspace.GuiPart.TouchEnded:connect(Close)

Help?
Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
30 Jun 2016 12:19 AM
Anyone know?
Report Abuse
Lem0nzzx is not online. Lem0nzzx
Joined: 08 Feb 2016
Total Posts: 1604
30 Jun 2016 12:22 AM
What's the variable p defined as?

if p == game.Players.LocalPlayer.Character.Torso then



Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
30 Jun 2016 12:59 AM
The variable is the "GuiPart"
Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
30 Jun 2016 01:45 AM
GuiPart as in- the part that activates and disables the GUI when touched.
Report Abuse
Lem0nzzx is not online. Lem0nzzx
Joined: 08 Feb 2016
Total Posts: 1604
30 Jun 2016 01:47 AM
So you're using a GuiPart as a toggle? That makes no sense...


Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
30 Jun 2016 02:42 AM
What is it that's confusing you? It's basically just a part (named GuiPart in Workspace), that you step on. A GUI shows up on your screen. Then, when you walk off of the part (GuiPart), the GUI isn't there anymore unless you step on GuiPart again.
Report Abuse
kaspar1230 is not online. kaspar1230
Joined: 25 Apr 2013
Total Posts: 481
30 Jun 2016 04:27 AM
make like a circle of invisible part around the part and when you touch one of the invisible part it destroys the gui from your playergui


#code game.players.kaspar1230:Remove("hahaa kicked")
Report Abuse
Meowth552 is not online. Meowth552
Joined: 17 Dec 2009
Total Posts: 2181
30 Jun 2016 04:37 AM
local Gui = game.Workspace.GuiPart

function GiveGui(Player)
if Player.PlayerGui:FindFirstChild(Gui.Name)~=nil then return end
script.Parent.Visible = true
end

Workspace.GuiPart.TouchEnded:connect(function(otherPart)
if p == game.Players.LocalPlayer.Character.Torso then
script.Parent.Visible = false

end

game.Workspace.GuiPart.Touched:connect(Open)
game.Workspace.GuiPart.TouchEnded:connect(Close)

--Probably.
Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
30 Jun 2016 03:53 PM
Ah shoot, It didn't work
Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
30 Jun 2016 04:06 PM
This is the fully functioning script that works when you step onto the Gui.

local Gui = game.Workspace.GuiPart

function GiveGui(Player)
if Player.PlayerGui:FindFirstChild(Gui.Name)~=nil then return end
Gui:Clone().Parent=Player.PlayerGui
end

script.Parent.Touched:connect(function(hit)

local Player=game.Players:GetPlayerFromCharacter(hit.Parent)
if Player==nil then return end
GiveGui(Player)

end)


You've stepped on the Part! The Gui appears! Great! The issue is the next part, where I want the GUI to go away when you're not stepping on the part.
Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
30 Jun 2016 06:01 PM
Anyone?
Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
30 Jun 2016 07:06 PM
Bump (I'm sorry! It's just because I'm still stumped! D:)
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