Part = script.Parent
local player = game.Players:FindFirstChild(hit.Parent.Name)
local debounce = false
------------------------------------
modelname="Prisoners" -- Put the EXACT name of the team here
------------------------------------
function onTouched(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
if (human ~= nil ) then
if game.Players:playerFromCharacter(hit.Parent).TeamColor==game.Teams:findFirstChild(modelname).TeamColor then
if debounce == false then
debounce = true
player.leaderstats.Money.Value = player.leaderstats.Money.Value + 100
human.Parent.HumanoidRootPart.Anchored = true
wait(5)
human.Parent.HumanoidRootPart.Anchored = false
human.Parent:MoveTo(workspace.Prison.Position)
wait(10)
debounce = false
end
end
end
end
connection = Part.Touched:connect(onTouched)
That’s what my change does, Part is your variable that contains the part for the handcuffs, it gets its parent, the tool, and then it gets its parent, the character who has the handcuffs tool, and then it gets the name of who has the handcuffs tool find finds the player from there
Huh? What is your entire code as of now? Maybe try this?
local Part = script.Parent
local player = game.Players:FindFirstChild(Part.Parent.Parent.Name)
local debounce = false
------------------------------------
modelname="Prisoners" -- Put the EXACT name of the team here
------------------------------------
function onTouched(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
if (human ~= nil ) then
if game.Players:GetPlayerFromCharacter(hit.Parent).TeamColor==game.Teams:findFirstChild(modelname).TeamColor then
if debounce == false then
debounce = true
player.leaderstats.Money.Value += 100
human.Parent.HumanoidRootPart.Anchored = true
wait(5)
human.Parent.HumanoidRootPart.Anchored = false
human.Parent:MoveTo(workspace.Prison.Position)
wait(10)
debounce = false
end
end
end
end
connection = Part.Touched:connect(onTouched)
Part = script.Parent
local debounce = false
local player = game.Players:FindFirstChild(Part.Parent.Parent.Name)
------------------------------------
modelname="Criminals" -- Put the EXACT name of the team here
------------------------------------
function onTouched(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
if (human ~= nil ) then
if game.Players:playerFromCharacter(hit.Parent).TeamColor==game.Teams:findFirstChild(modelname).TeamColor then
if debounce == false then
debounce = true
player.leaderstats.Money.Value += 100
local name = hit.Parent.Name
local player = game.Players:FindFirstChild(name)
player.TeamColor = BrickColor.new("Deep orange")
human.Health = 0
wait(10)
debounce = false
end
end
end
end
connection = Part.Touched:connect(onTouched)
Yeah because you seem to be using some inefficient way to handle a cuff tool, I don’t really recommend using .Touched, you’d obviously face a lot of errors, It’s better if you use Input management for a cuff tool
UserInputService [client] you can use it to detect input like MouseClick then decide what to do with that Remote Functions and Events [server <-> client] so you can link and make a communication between Client <-> Server
Then on the server code you would just handle properties, data, instances, teaming.etc
If you have any trouble understanding this then you can look up tutorials
Can’t you use the MouseDown event of the player’s mouse that Tool.Equipped gives so when you click it it’ll arrest the first person touching the handcuffs?
local Part = script.Parent
local debounce = false
------------------------------------
modelname="Prisoners" -- Put the EXACT name of the team here
------------------------------------
function onTouched(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
local player = game.Players:GetPlayerFromCharacter(Part.Parent.Parent)
local prisonerPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
if debounce or not player or not human or not prisonerPlayer then return end
if prisonerPlayer.TeamColor == game.Teams[modelname].TeamColor then
debounce = true
player.leaderstats.Money.Value += 100
human.Parent.HumanoidRootPart.Anchored = true
wait(5)
human.Parent.HumanoidRootPart.Anchored = false
human.Parent:MoveTo(workspace.Prison.Position)
wait(10)
debounce = false
end
end
connection = Part.Touched:connect(onTouched)