Yeha, the title basically says it all. When I run this code it only gets “player1” during 2 player test, but not “Player 2”. This script is supposed to scan players in the players section of explorer, get their character and if the character is close enough it adds a proximity prompt in the humanoid root part.
In this case, it’s only checking player 1, which is the player that’s holding the brick (This script is for handcuffs btw)
here’s the script (Local)
local Equipped = nil
local Tool = script.Parent.Parent
Tool.Equipped:Connect(function(mouse)
print("A tool was equipped")
Equipped = true
end)
Tool.Unequipped:Connect(function()
print("The tool was unequipped")
Equipped = false
end)
local RunService = game:GetService("RunService")
local RATE_PER_SECOND = 20
RunService.RenderStepped:Connect(function(step)
local increment = RATE_PER_SECOND * step
if Equipped == true then
print("Run")
-- Generic for-loop example
local children = game.Players:GetChildren()
for i, playerInPlayers in ipairs(children) do
print(playerInPlayers.Name .. " is child number " .. i)
if playerInPlayers.ClassName ~= "Player" then print("Bruh") return end
if playerInPlayers.Name == Tool.Parent.Name then return end
local char = nil
local HRP = nil
if playerInPlayers.Character then
char = playerInPlayers.Character
HRP = char.HumanoidRootPart
else
return
end
local magnitude = (script.Parent.Position - HRP.Position).Magnitude
print(magnitude)
if magnitude <= 10 then
print("Close enough")
local prompt = Instance.new("ProximityPrompt")
prompt.Parent = HRP
prompt.Enabled = true
prompt.HoldDuration = 4
prompt.Name = "HoldToarrest"
elseif magnitude > 10 then
print("Far")
if not HRP:FindFirstChild("HoldToarrest") then
print("No Prompt")
else
HRP.HoldToarrest:Destroy()
end
end
end
end
end)
At first I figured it was maybe something to do with renderstepped and maybe thought that the increment was too small, but it didn’t seem to fix anything when I made it higher.