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: Duplicated GUIs -- Help?

Previous Thread :: Next Thread 
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
26 Oct 2016 04:23 PM
I have a script here, that is supposed to give you a GUI (once) when a part is touched. However, It seems to give out the GUI more than once and they overlay on top of each other. I can't figure out how to only have a single GUI be given to me. (I'm bad at explaining, I really hope that made sense..?)

function onTouch(hit)

local ptt = game.Players:playerFromCharacter(hit.Parent)
if ptt == nil then return end
local wfp = script.Parent:findFirstChild("GuiName"):clone()
if wfp == nil then return end
wfp.Parent = ptt.PlayerGui

end

script.Parent.Touched:connect(onTouch)
Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
01 Nov 2016 04:47 PM
bump
Report Abuse
Lordux is not online. Lordux
Joined: 10 Jun 2010
Total Posts: 610
01 Nov 2016 05:11 PM
Add a debounce.

If you don't know what that is it could just be a variable. Your function would only add the GUI if the debounce is ready.
Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
01 Nov 2016 05:13 PM
I'm so sorry to bother anyone with this, I can't figure out how to add the debounce. The script keeps breaking.
Report Abuse
Lordux is not online. Lordux
Joined: 10 Jun 2010
Total Posts: 610
01 Nov 2016 11:56 PM
Debounce = true
function onTouch(hit)
If Debounce == true then
Debounce = false
local ptt = game.Players:playerFromCharacter(hit.Parent)
if ptt == nil then return end
local wfp = script.Parent:findFirstChild("GuiName"):clone()
if wfp == nil then return end
wfp.Parent = ptt.PlayerGui
. wait(5)
Debounce = true
end
end

script.Parent.Touched:connect(onTouch)
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
02 Nov 2016 12:00 AM
I hate when people use a debounce on things like this that doesn't check which player needs to not activate it again. Its annoying when you have to wait 5 seconds because someone else just touched it, and possible not even get to use it if it happens to pick them to activate again.
Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
04 Nov 2016 09:15 PM
^ Is there anything else you recommend to solve the problem other than a debounce then?
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
04 Nov 2016 09:17 PM
make it so that if the player already has the Gui the new one that gets cloned is instantly destroyed

or you can save a list of the players who have the gui in a table

or you can use boolvalues for the players to detect who already has the gui

lots of ways
Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
04 Nov 2016 09:20 PM
Thank you so much for your time Lordux, the script helped !!
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
04 Nov 2016 09:33 PM
Wouldn't even need a debounce.
I added:
if ptt.PlayerGui:FindFirstChild("GuiName") then return end

I tested it also



local scr=script.Parent
local function onTouch(hit)
if hit.Parent:WaitForChild("Humanoid") then
local ptt=game.Players:playerFromCharacter(hit.Parent)
if ptt.PlayerGui:FindFirstChild("GuiName") then return end
local wfp=scr:FindFirstChild("GuiName"):Clone()
if wfp==nil then return end
wfp.Parent=ptt.PlayerGui
end
end


Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
04 Nov 2016 09:34 PM
Roblox takes out the last line when copypasta great

local scr=script.Parent
local function onTouch(hit)
if hit.Parent:WaitForChild("Humanoid") then
local ptt=game.Players:playerFromCharacter(hit.Parent)
if ptt.PlayerGui:FindFirstChild("GuiName") then return end
local wfp=scr:FindFirstChild("GuiName"):Clone()
if wfp==nil then return end
wfp.Parent=ptt.PlayerGui
end
end
scr.Touched:connect(onTouch)


Report Abuse
xCrystalGem is not online. xCrystalGem
Joined: 08 Jan 2016
Total Posts: 220
05 Nov 2016 02:53 PM
^ Thank you so much!! It works :,)
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