i am trying to make a handcuff system where when a police officer on the guards team holds out their handcuff it will enable all proximity prompts to arrest robbers on the robber team. However when holding out their handcuff it only enables the prompt on the guard holding the handcuff and not the other robbers. how do i make it so the prompt does not show on other guards or the player holding the cuffs but show on robbers?
– clientScript
local tool = script.Parent
local bodyAttach = tool:WaitForChild("bodyAttach")
local anim = bodyAttach:WaitForChild("equipAnim")
local players = game:GetService("Players")
local playerr = players.LocalPlayer
local char = playerr.Character or playerr.CharacterAdded:Wait()
local rightArm = char:FindFirstChild("Right Arm")
local rep = game:GetService("ReplicatedStorage")
local itemsEvent = rep:WaitForChild("mechanics"):WaitForChild("items"):WaitForChild("createMotor")
local load = char:WaitForChild("Humanoid"):LoadAnimation(anim)
local function showPrompts(show)
for _, Player in ipairs(players:GetChildren()) do
if Player:IsA("Player") then
local character = Player.Character or Player.CharacterAdded:Wait()
local humanoidRootPart = char:WaitForChild("HumanoidRootPart")
local prompt = humanoidRootPart:WaitForChild("arrestPropmpt")
if Player.Team.Name == "robbers" then
if prompt then
prompt.Enabled = show
end
elseif Player.Team.Name == "guards" then
if prompt then
prompt.Enabled = false
end
end
end
end
end
tool.Equipped:Connect(function()
itemsEvent:FireServer("create", bodyAttach)
rightArm.ToolAttach.Part0 = rightArm
rightArm.ToolAttach.Part1 = bodyAttach
load:Play()
showPrompts(true)
end)
tool.Unequipped:Connect(function()
itemsEvent:FireServer("destroy", bodyAttach)
load:Stop()
showPrompts(false)
end)
– server
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humaniodRootPart = character:WaitForChild("HumanoidRootPart")
local prompt = Instance.new("ProximityPrompt")
prompt.Name = "arrestPropmpt"
prompt.ActionText = "arrest"
prompt.MaxActivationDistance = 10
prompt.RequiresLineOfSight = false
prompt.Style = Enum.ProximityPromptStyle.Custom
prompt.Enabled = false
prompt.Parent = humaniodRootPart
end)
end)