Prompt not Showing

The prompt doesn’t show, It’s said its already inside of a humanoid root part. It wont show. I need help
its in a local script

local Police = game.Teams.Police
local Criminal = game.Teams.Criminal
local player = game.Players.LocalPlayer

local function checkCriminals()
	for _, criminalPlayer in pairs(game.Players:GetPlayers()) do
		if criminalPlayer.Team == Criminal then
			local ArrestPlayerName = criminalPlayer.Name

			if criminalPlayer.Character.HumanoidRootPart:FindFirstChild("ArrestPrompt") then
				local ProxPrompt = Instance.new("ProximityPrompt")
				ProxPrompt.Name = "ArrestPrompt"
				local AddTag = Instance.new("StringValue")
				local ArrestPlayerName = criminalPlayer
				ProxPrompt.Parent = criminalPlayer.Character:FindFirstChild("HumanoidRootPart")
				ProxPrompt.MaxActivationDistance = 10
				ProxPrompt.HoldDuration = 0.65
				ProxPrompt.ObjectText = ArrestPlayerName
				ProxPrompt.ActionText = "Arrest"
				ProxPrompt.RequiresLineOfSight = true
				ProxPrompt.Enabled = true
				
				if player.Team == game.Teams.Police then
					ProxPrompt.Enabled = true
				end

				ProxPrompt.Triggered:Connect(function()
					game.ReplicatedStorage.PlayerEvents.Arrest:FireServer(ArrestPlayerName)
				end)
			end
		end
	end
end


game:GetService("RunService").RenderStepped:Connect(function()
	if player.Team == Police then
		checkCriminals()
	end
end)

Have you tried disabling RequiresLineOfSight?

1 Like

I tried disabled it and still wont show

Oh yea i forgot to tell its in a local script

1 Like

Well that’s definitely a relatable bug.

The code won’t run if the prompt doesn’t exist.

1 Like

The parent for the prompt was located inside of a criminal’s humanoid root part, I checked the debug and the print states that it’s located in the humanoid root part.

Even still, you should only add a prox prompt if the player doesn’t already have one
Also ArrestPlayerName is an instance, not a string. Change ArrestPlayerName = criminalPlayer.Name after the add tag name (Also you already created a variable for the name above, why create another one?)
Final code. I will optimise this for you a bit:

local Police = game.Teams.Police
local Criminal = game.Teams.Criminal
local player = game.Players.LocalPlayer

local function checkCriminals()
	for _, criminalPlayer in pairs(Criminal:GetPlayers()) do
			local ArrestPlayerName = criminalPlayer.Name

			if criminalplayer.Character.HumanoidRootPart and not criminalPlayer.Character.HumanoidRootPart:FindFirstChild("ArrestPrompt") then
				local ProxPrompt = Instance.new("ProximityPrompt")
				ProxPrompt.Name = "ArrestPrompt"
				local AddTag = Instance.new("StringValue")
				ProxPrompt.Parent = criminalPlayer.Character:FindFirstChild("HumanoidRootPart")
				ProxPrompt.MaxActivationDistance = 10
				ProxPrompt.HoldDuration = 0.65
				ProxPrompt.ObjectText = ArrestPlayerName
				ProxPrompt.ActionText = "Arrest"
				ProxPrompt.RequiresLineOfSight = true
				ProxPrompt.Enabled = true
				
				if player.Team ==Police then
                     ProxPrompt.Enabled = true
				else
                     ProxPrompt.Enabled = false
                end

				ProxPrompt.Triggered:Connect(function()
					game.ReplicatedStorage.PlayerEvents.Arrest:FireServer(ArrestPlayerName)
				end)
			end
		end
	end
end


game:GetService("RunService").RenderStepped:Connect(function()
	if player.Team == Police then
		checkCriminals()
	end
end)```
1 Like

I rescripted this and adding tags to the game. I solved it, thanks for helping.

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