Hi, the problem I’m facing is that the cuffs are really laggy when they move the character, I’m 90% I know why this happens but I have no clue how to fix it.
Anyone?
repeat wait() until game.ReplicatedStorage:FindFirstChild("DetainEvent")
local RemoteEvent = game.ReplicatedStorage.DetainEvent
local RunService = game:GetService("RunService")
local Enabled = {}
RemoteEvent.OnServerEvent:Connect(function(plr,purpose,mousetarget)
if plr ~= nil and purpose == "detain" then
if mousetarget.Parent:FindFirstChildOfClass("Humanoid") then
if not mousetarget.Parent:FindFirstChild("Detain") then
Enabled[plr.Name] = true
spawn(function()
repeat
mousetarget.Parent:FindFirstChildOfClass("Humanoid"):UnequipTools()
if mousetarget.Parent:FindFirstChild("UpperTorso") then
mousetarget.Parent.UpperTorso.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new( 0, 0, -5 )
else
mousetarget.Parent.Torso.CFrame = plr.Character.HumanoidRootPart.CFrame * CFrame.new( 0, 0, -5 )
end
RunService.Heartbeat:Wait()
until Enabled[plr.Name] == false
end)
end
else
Enabled[plr.Name] = false
RemoteEvent:FireClient(plr,"noOneToDetain")
end
elseif purpose == "undetain" then
Enabled[plr.Name] = false
end
end)