Help With UI HitBox

I am trying to make a team UI switcher and when I hit a part the UI comes up like this


and when you hit Get Tag you get the tag like this and the UI disappears

Problem: After getting the tag and the the UI goes away everything is fine but when I move agine the UI comes back up. How do I make it so the UI does not come back up?

--LOCAL SCRIPT IN STARTERGUI
---> variables
local Animator = game.Workspace.Map.Jobs.HitBoxes:WaitForChild("Animator")

---> main
Animator.Touched:Connect(function(Hit)
	spawn(function()
		if Hit.Parent:FindFirstChild("Humanoid") then
			script.Parent.Parent.JobUI.AnimatorFrame.Visible = true
			repeat task.wait() until (Animator.Position - Hit.Parent.HumanoidRootPart.Position).magnitude >= 12
			script.Parent.Parent.JobUI.AnimatorFrame.Visible = false
		end
			end)
end)
3 Likes

is this a localscript or normal script? edit: oops sorry i didn’t see that it said it was localscript, let me try to help

the reason it shows up again, is because when you touch the hitbox it runs the “Animator.Touched” function, then it makes the UI visible again with script.Parent.Parent.JobUI.AnimatorFrame.Visible = true so you have to add script.Parent.Parent.JobUI.AnimatorFrame.Enabled = false so it doesnt become visible again

--LOCAL SCRIPT IN STARTERGUI
---> variables
local Animator = game.Workspace.Map.Jobs.HitBoxes:WaitForChild("Animator")

---> main
Animator.Touched:Connect(function(Hit)
	spawn(function()
		if Hit.Parent:FindFirstChild("Humanoid") then
			script.Parent.Parent.JobUI.AnimatorFrame.Visible = true
			repeat task.wait() until (Animator.Position - Hit.Parent.HumanoidRootPart.Position).magnitude >= 12
			script.Parent.Parent.JobUI.AnimatorFrame.Visible = false
script.Parent.Parent.JobUI.AnimatorFrame.Enabled = false --just add this simple line and it should work
		end
			end)
end)

This comes up
Enabled is not a valid member of Frame "Players.Cyber_Designer.PlayerGui.JobUI.AnimatorFrame

try replacing script.Parent.Parent.JobUI.AnimatorFrame.Enabled = false with script.Parent.Parent.JobUI.Enabled = false

That works but I can’t do that because I have other UI in JobUI

1 Like

hold on wait a second

char limit

try

local Animator = game.Workspace.Map.Jobs.HitBoxes:WaitForChild("Animator")
local player = game.Players.LocalPlayer
local job = Instance.new("StringValue", player)

---> main
Animator.Touched:Connect(function(Hit)
	spawn(function()
		if Hit.Parent:FindFirstChild("Humanoid") then
			if job.Value ~= "Animator" then
				script.Parent.Parent.JobUI.AnimatorFrame.Visible = true
				repeat task.wait() until (Animator.Position - Hit.Parent.HumanoidRootPart.Position).magnitude >= 12
				script.Parent.Parent.JobUI.AnimatorFrame.Visible = false
				job.Value = "Animator"
			end
		end
	end)
end)

It come up with no error and it also makes the UI come right up after you hit Get Tag

local Animator = game.Workspace.Map.Jobs.HitBoxes:WaitForChild("Animator")
local player = game.Players.LocalPlayer
local job = Instance.new("StringValue", player)
job.Name = "Job"

---> main
Animator.Touched:Connect(function(Hit)
	spawn(function()
		if Hit.Parent:FindFirstChild("Humanoid") then
			if job.Value == "Animator" then
				-- do nothing
			else
				script.Parent.Parent.JobUI.AnimatorFrame.Visible = true
				repeat task.wait() until (Animator.Position - Hit.Parent.HumanoidRootPart.Position).magnitude >= 12
				script.Parent.Parent.JobUI.AnimatorFrame.Visible = false
				job.Value = "Animator"
			end
		end
	end)
end)

When I play the UI comes up after hitting Get Tag but it comes up not as fast as the other one

can you tell me where the title (on the players head is located)?
example: script.Parent.Title

I don’t know how to do that but the players Head UI in not the problem the UI that comes up is just UI in StarterGui

I have another script that does that

actually, i do need it, because i want to check for it in the script.

i mean like, where is the title located, in the players head?

Here ha ya is in the players head

-- SERVER SCRIPT INSIDE SERVERSCRIPTSERVICE
---> services
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		---> variables
		local NameTagClone = game.ServerStorage.HeadUI:Clone()

		---> main
		NameTagClone.Parent = char.Head
		NameTagClone.Adornee = char.Head

		NameTagClone.UI.NameUI.NameName.Text = char.Name

		if plr.Team == nil then
			NameTagClone.UI.JobUI.JobName.Text = "Player"
		end

		repeat wait() until plr.Team ~= nil

		NameTagClone.UI.JobUI.JobName.Text = plr.Team.Name

		char.Humanoid.DisplayDistanceType = "None"

		game:GetService("RunService").Heartbeat:Connect(function()
			NameTagClone.UI.JobUI.JobName.Text = plr.Team.Name
		end)
	end)
end)

what are all the teams?

char limit

Animator, Artist, Builder, ClothingDesigner, Composer, Modeler, Scripter, and UIDesigner

1 Like
--LOCAL SCRIPT IN STARTERGUI
---> variables
local Animator = game.Workspace.Map.Jobs.HitBoxes:WaitForChild("Animator")

---> main
Animator.Touched:Connect(function(Hit)
	spawn(function()
		if Hit.Parent:FindFirstChild("Humanoid") then
			local headui = Hit.Parent.Head.HeadUI
			if headui then
				if headui.UI.JobUI.JobName.Text ~= "Animator" then
					script.Parent.Parent.JobUI.AnimatorFrame.Visible = true
					repeat task.wait() until (Animator.Position - Hit.Parent.HumanoidRootPart.Position).magnitude >= 12
					script.Parent.Parent.JobUI.AnimatorFrame.Visible = false
					headui.UI.JobUI.JobName.Text = "Animator"
					end
				end
		end
	end)
end)

No Error! Works Great!! Thank You!!!