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

What's wrong with this?

local deb = false

script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if deb == true then return end
		deb = true
wait()
local a = game.Players:GetPlayerFromCharacter(hit.Parent)
repeat wait() until a:FindFirstChild("PlayerGui")
local b = a.PlayerGui:GetChildren()
for i=1, #b do
if b[i].className == "ScreenGui" then
return end
end
			script.Parent.CanCollide = false
end
	deb = false
end)

It checks to see if the player touching it has any guis inside him. If he doesn't, the brick becomes noncancollide. It works in solo but not in server for some reason.

1 answer

If the gui is present, the function returns before it gets a chance to disable the debounce. After testing the fixed version, it works fine in both server and solo.

local deb = false

script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if deb == true then return end
		deb = true
		local a = game.Players:GetPlayerFromCharacter(hit.Parent)
		repeat wait() until a:FindFirstChild("PlayerGui")
		local b = a.PlayerGui:GetChildren()
		for i=1, #b do
			if b[i].className == "ScreenGui" then
			deb = false
			return end
		end
		script.Parent.CanCollide = false
	end
	deb = false
end)

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