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