Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

GUI open script doesn't work?

So, I used this to make a GUI open by a part touch, but when I tested it in studio it worked, in game.. It worked when I touched it while I was alone in the server, but when I told someone to join the part didn't open to GUI for me, or the other person...!

debounce = false
GUIopen = script.Parent.Value

function onTouched(hit)
    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    if plr and debounce == false then
		if GUIopen.Value == false then
       		debounce = true
       	 	GUIopen.Value = true
			wait(0.1)	
			plr:WaitForChild("PlayerGui").TeleportMenu.Background.Visible = false
        	debounce = false
		end
    end
end

script.Parent.Touched:connect(onTouched

Help please D:

2 comments

0

Are there any errors? Do you ever disable GUIopen?

0

No errors, yeah I put a scipt in the "Close" button in the GUI thats ment to open, that makes the boolvalue of the GUIopen false when pressed...

1 answer

Ok I finally found out what your error was, The error was the use of Debounces, Here is the fixed Code:

debounce=false
function onTouched(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
wait(0.1)
if not debounce then
debounce=true
plr.PlayerGui.TeleportMenu.Background.Visible = false
end
debounce=false
end

script.Parent.Touched:connect(onTouched)

I edited it a bit, I changed the Postitions of the Debounces, If there are any errors just comment below.

Note: I had removed the BoolValue

3 comments

0

Yeah, but then when a player steps on it, the GUI opens itself way too may times....

0

Oh I see let me update it.

0

Why not just use the debounce conditional from the start of the function? That way you don't even have to go about the 'wait' statement and the compiler won't bother referencing plr each time debounce might be false

This discussion is preserved as it was. New answers, comments, and votes are closed.