|
| 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
|
  |
| 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 |
|
|
|
| 28 Jun 2016 10:42 PM |
| I'm sorry, I got some kind of "Certificate error" when I clicked your link :< |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 28 Jun 2016 10:51 PM |
wiki.roblox.com/index.php?title=API:Class/BasePart/TouchEnded
|
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 08 Feb 2014 |
| Total Posts: 700 |
|
|
| 29 Jun 2016 02:03 PM |
Nvm, MarketPlaceService worked, sorry for the confusion.
|
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
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 |
|
|
|
| 30 Jun 2016 12:59 AM |
| The variable is the "GuiPart" |
|
|
| Report Abuse |
|
|
|
| 30 Jun 2016 01:45 AM |
| GuiPart as in- the part that activates and disables the GUI when touched. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|
|
| 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 |
|
|
| |
|
|
| 30 Jun 2016 07:06 PM |
| Bump (I'm sorry! It's just because I'm still stumped! D:) |
|
|
| Report Abuse |
|
|