How would I check if a player has a cloned GUI on their head?

How would I check if a player has a specific cloned GUI on their head, and how would I destroy that cloned GUI if the GUI’s parent is the players head?

Are you storing the nametag in the players head?

as in the cloned GUI’s parent? Then yes.

1 Like

Check if a part exists:

local ExpectedLocation = game.Workspace
local LookingFor = "Part"

if ExpectedLocation:FindFirstChild(LookingFor) then
	print("Found part")
end

You can delete with:

Instance:Destroy()

Just tried it, and it’s not working.

This is my code:

local HttpService = game:GetService("HttpService")
local ReplicatedStorage = game.ReplicatedStorage
local MinRank = script.MinRank.Value
local prefix = ";"
local ServerStorage = game:GetService('ServerStorage')
local auth_overhead = ServerStorage:WaitForChild('auth_overhead')

local function FindPlr(plr)
	local foundPlr = nil
	local plrs = game.Players:GetPlayers()
	for i = 1, #plrs do
		local current = plrs[i]
		if string.lower(current.Name):sub(1, #plr) == string.lower(plr) then
			foundPlr = current.Name
			break
		end
	end
	return foundPlr
end


game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
		if player:IsInGroup('GROUP_ID') == true then
		local LowerCaseMessage = string.lower(msg)
			if string.find(LowerCaseMessage, ";auth") or string.find(LowerCaseMessage, ";authorize") then --Look for the rank command to be used
					local SplitMessage = string.split(msg, " ") --Split the message
				local full_player = FindPlr(SplitMessage[2]) --Get the 2nd word in the message
				local playerInstance = game.Players:FindFirstChild(player.Name)
				local found = game.Players:FindFirstChild(full_player)
				local ui = auth_overhead:Clone()
				if found.Character.Head:FindFirstChild(ui) then
					ui:Destroy()
					print('deauthed')
					else
					ui.Parent = found.Character.Head
					print('authed')
				end
			end
		end
	end)
end)

Replace ui, with ui.Name, also replace UI with found.Character.Head:FindFirstChild(ui).

Also check logs, it’s not good showing somebody broken script unless you have the logs.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.