GUI showing for everyone!

I’m pretty new to scripting but I’m trying to make it so only a certain rank from a group can see the GUI when touched. It does work, however, the GUI shows for everyone when that person touches it. I want it so only the person from the group, who touches it, is the only person who sees it.

Image:
Capture

Setup Script:

script.Parent:WaitForChild("TouchPart1").Parent = game.Workspace
script.Parent:WaitForChild("Office1").Parent = game.StarterGui
wait()
script.Parent:Destroy()

Code Script:

GroupId = 9392267 
min = 255
max = 255

local part = game.Workspace.TouchPart1
local distance = 2.5
script.Parent.Enabled = false
part.Touched:connect(function(p)
-- Group Checker
	local Human = p.Parent:findFirstChild("Humanoid")
	if p.Parent then
		pName=game.Players:getPlayerFromCharacter(p.Parent)
		if p then 
			if pName:GetRankInGroup(GroupId) >= min and pName:GetRankInGroup(GroupId) <= max then
--Script
				if p.Parent.Humanoid then
					script.Parent.Enabled = true
					while true do
						local a = ((part.Size.X+part.Size.Y+part.Size.Z)/3)
						if (p.Position-part.Position).magnitude >= (distance+a) then
							script.Parent.Enabled = false
							break
						end
						wait()
					end
				end
			end
		end
	end
end)

if pName:GetRankInGroup(GroupId) >= min and pName:GetRankInGroup(GroupId) <= max then

Should be

if p:isInGroup(groupId) then

Is this what you are looking for?

Sorry, I probably didn’t make sense. The group part works well, the problem is that when I touch the part, it showed for everyone instead of the person who touched it.

It looks like you’re parenting the gui to the game’s StarterGui which replicates to everyone. Parent it to the player’s PlayerGui instead.

I’m pretty sure you just need it to be a LocalScript, not a normal script.

LocalScripts change it for only one client, Script, however, does it for the whole server instead.

Put the script in a LocalScript and check if the player that touched the part is the LocalPlayer