Gybro
|
  |
| Joined: 23 Apr 2014 |
| Total Posts: 808 |
|
|
| 14 May 2014 05:04 PM |
game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key) key = key:lower() if key == "e" then --key function GetGui() for i, v in pairs(script:GetChildren()) do if v:IsA("ScreenGui") then return v end end return nil end Gui = GetGui() Gui.Name = script.Parent.Parent.Name .. "TalkGui" script.Parent.Parent.Changed:connect(function() GetGui().Name = script.Parent.Parent.Name .. "TalkGui" end) while true do wait(.1) for i, v in pairs(game.Players:GetChildren()) do if v.Character ~= nil then if v.Character:FindFirstChild("Torso") ~= nil and (script.Parent.Position - v.Character.Torso.Position).magnitude <= 5 and v.PlayerGui:FindFirstChild(Gui.Name) == nil then Gui:Clone().Parent = v.PlayerGui
elseif v.Character:FindFirstChild("Torso") ~= nil and (script.Parent.Position - v.Character.Torso.Position).magnitude > 5 and (script.Parent.Position - v.Character.Torso.Position).magnitude < 7 then if v.PlayerGui:FindFirstChild(Gui.Name) then v.PlayerGui[Gui.Name]:Remove() end
end end end end
end end)
---------------
It only works once, when the GUI shows up whenever the player comes into proximity. |
|
|
| Report Abuse |
|
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 14 May 2014 05:08 PM |
What you need is a Bool value to check things and remove all locals if there are anything, then just add a script inside the script with this:
while wait(1) do script.Parent.Disabled = true script.Parent.Disabled = false end
That's how I solve my problems... |
|
|
| Report Abuse |
|
|
Gybro
|
  |
| Joined: 23 Apr 2014 |
| Total Posts: 808 |
|
|
| 14 May 2014 05:13 PM |
| It worked, but now the GUI won't leave the screen when the part is left OR when "e" is pressed again. |
|
|
| Report Abuse |
|
|
Gybro
|
  |
| Joined: 23 Apr 2014 |
| Total Posts: 808 |
|
| |
|
micke3212
|
  |
| Joined: 24 Nov 2009 |
| Total Posts: 3000 |
|
|
| 14 May 2014 05:21 PM |
| Like I stated, used a Bool Value inside the script to control movments and use a if bool.Value == true then and a elseif bool.Value == false and then have it were it sets them true... |
|
|
| Report Abuse |
|
|
Gybro
|
  |
| Joined: 23 Apr 2014 |
| Total Posts: 808 |
|
| |
|
Gybro
|
  |
| Joined: 23 Apr 2014 |
| Total Posts: 808 |
|
|
| 14 May 2014 05:32 PM |
| Wait, how do I get the GUI to disappear when E is pressed a second time? |
|
|
| Report Abuse |
|
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
|
| 14 May 2014 05:41 PM |
Findfirstchild to see if its there. If its there > destroy if u clone it. If its not there > create it |
|
|
| Report Abuse |
|
|
Gybro
|
  |
| Joined: 23 Apr 2014 |
| Total Posts: 808 |
|
|
| 14 May 2014 05:43 PM |
Wait, now when you press E once it won't go away if you walk away from the part, but if you press E a second time then walk away from the part, it disappears.
Help? |
|
|
| Report Abuse |
|
|
Gybro
|
  |
| Joined: 23 Apr 2014 |
| Total Posts: 808 |
|
|
| 14 May 2014 05:45 PM |
| (I didn't try vlek's thing yet) |
|
|
| Report Abuse |
|
|
Gybro
|
  |
| Joined: 23 Apr 2014 |
| Total Posts: 808 |
|
| |
|
Gybro
|
  |
| Joined: 23 Apr 2014 |
| Total Posts: 808 |
|
| |
|
Gybro
|
  |
| Joined: 23 Apr 2014 |
| Total Posts: 808 |
|
| |
|
Gybro
|
  |
| Joined: 23 Apr 2014 |
| Total Posts: 808 |
|
| |
|
Gybro
|
  |
| Joined: 23 Apr 2014 |
| Total Posts: 808 |
|
| |
|