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