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.
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)