Hi, I’m currently making a handcuffing system for a package that I will release. I’m having an issue where when the player clicks on someone, the player that clicks gets cuffed, instead of the person that they clicked. I can’t seem to figure out why this happens.
Client Script
local events = rs.HandcuffsEvents
local grabEvent = events.PlayerGrabbed
local tool = script.Parent
local plr = game.Players.LocalPlayer
local animation = script.Parent:WaitForChild("DetainedAnimation")
local mouse = plr:GetMouse()
local char = plr.Character
local hum = char.Humanoid
local animator = hum:WaitForChild("Animator")
local animClone = animation:Clone()
tool.Equipped:Connect(function(mouse)
tool.Activated:Connect(function()
if mouse.Target.Parent then
if mouse.Target.Parent:IsA("Accessory") then
print(mouse.Target.Parent.Parent)
local plrTarget = mouse.Target.Parent.Parent
grabEvent:FireServer(mouse.Target)
elseif mouse.Target.Parent:IsA("Model") then
print(mouse.Target.Parent)
local plrTarget = mouse.Target.Parent
grabEvent:FireServer(mouse.Target)
else end
end
end)
end)
Server Script
local events = rs.HandcuffsEvents
local grabEvent = events.PlayerGrabbed
grabEvent.OnServerEvent:Connect(function(mouseTarget)
local animClone = script.Parent.DetainedAnimation:Clone()
animClone.Parent = mouseTarget
local animTrack = mouseTarget.Character.Humanoid.Animator:LoadAnimation(animClone)
animTrack:Play()
task.wait(.24)
animTrack:AdjustSpeed(0)
end)
Any help is much appreciated! Thank you.