Hi, so I am trying to make a Detain Tool. Since while true do is too unsmooth, I’ve tried renderstepped which works great but only on the Client. If I use NetworkOwnership to transfer it to the Client, then it’s smooth for the player to detain but laggy for the other person. My question is, is it possible to have something faster than heartbeat on the server?
Server script:
--++++++++++++++++++++++++++//<<>>\\++++++++++++++++++++++++++--
local Detain_Event = game.ReplicatedStorage:WaitForChild("Detain")
local RunService = game:GetService("RunService")
--++++++++++++++++++++++++++//<<>>\\++++++++++++++++++++++++++--
Detain_Event.OnServerEvent:Connect(function(player, target)
if player.Backpack:FindFirstChild("Detain") or player.Character:FindFirstChild("Detain") then
RunService.Heartbeat:Connect(function()
target.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5)
end)
else
player:Kick("[INTERSTELLAR] \n \n You have been kicked from the game! \n Reason: \n Exploited Tool Ussage \n \n By: \n Interstellar Automation")
end
end)
Client Script:
--++++++++++++++++++++++++++//<<>>\\++++++++++++++++++++++++++--
local Mouse = game.Players.LocalPlayer:GetMouse()
local Detain_Event = game.ReplicatedStorage:WaitForChild("Detain")
local player = game.Players.LocalPlayer
--++++++++++++++++++++++++++//<<>>\\++++++++++++++++++++++++++--
script.Parent.Activated:Connect(function()
local raw_Target = Mouse.Target
if raw_Target.Parent:FindFirstChild("Humanoid") then
local Target = game.Players:GetPlayerFromCharacter(raw_Target.Parent)
if Target then
if (Target.Character.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).Magnitude <= 15 then
print("[CORE]: Detaining player "..Target.Name.." = possible. Magnitude <= 15; Clearance on Server being checked.")
Detain_Event:FireServer(Target)
end
end
end
end)
print("[CORE]: Detain Core has been loaded for player-instance; "..game.Players.LocalPlayer.Name.."!")
I have one of the smoothest cuff modules I’ve seen in games I’ve played and it uses welding and remotes. I can’t remember exactly how it’s done in my game off the top of my head.
Constantly setting player position, vectors or cframes in a loop - especially as a heartbeat on the server is taxing in terms of performance.
Detain_Event.OnServerEvent:Connect(function(player, target)
if player.Backpack:FindFirstChild("Detain") or player.Character:FindFirstChild("Detain") then
local bp = Instance.new("BodyPosition")
bp.Parent = target.Character.HumanoidRootPart
bp.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
RunService.Heartbeat:Connect(function()
--target.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5)
bp.Position = player.Character.HumanoidRootPart.Position+player.Character.HumanoidRootPart.CFrame.LookVector*5
end)
else
player:Kick("[INTERSTELLAR] \n \n You have been kicked from the game! \n Reason: \n Exploited Tool Ussage \n \n By: \n Interstellar Automation")
end
end)
https://gyazo.com/dff46f37447bf9f0f3ad1e9b9d56559f
It is important that it instantly teleports him infront of you that it looks like there is no delay.
I think welding or NetworkOwnership is the only possible solution here.
Yes. There is no way to make it smooth on all clients.
Unless you animate it on all of the clients.
But doing so would be unnecessary, so the best compromise is doing it on the detained client, and on the server.
Area47, Area27 etc have this sort of Detain Tools which are Smooth. So it is possible.
Also, if it is unsmooth on the Server then ppl could abuse that and kill the person with our gun system.
There is no way to make it faster on the server. .Stepped runs on each physic step so on the server it is perfect.
The reason it seems delayed because it takes time to send it to the clients.
Hence you should also do it on the clients.
And about the gun system, an exploiter could abuse it like that anyways. So you would have to secure the gunsystem on the server by securing the gun remotes.
--++++++++++++++++++++++++++//<<>>\\++++++++++++++++++++++++++--
local Detain_Event = game.ReplicatedStorage:WaitForChild("Detain")
local RunService = game:GetService("RunService")
--++++++++++++++++++++++++++//<<>>\\++++++++++++++++++++++++++--
Detain_Event.OnServerEvent:Connect(function(player, target)
if player.Backpack:FindFirstChild("Detain") or player.Character:FindFirstChild("Detain") then
if target.Character.HumanoidRootPart:FindFirstChild("Detain_Weld") then
target.Character.HumanoidRootPart.Detain_Weld:Destroy()
else
target.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5)
local Weld = Instance.new("ManualWeld",target.Character.HumanoidRootPart)
Weld.Part0 = target.Character.HumanoidRootPart
Weld.Part1 = player.Character.HumanoidRootPart
end
else
player:Kick("[INTERSTELLAR] \n \n You have been kicked from the game! \n Reason: \n Exploited Tool Ussage \n \n By: \n Interstellar Automation")
end
end)
I’ve tried Manual and normal Weld, both just glues them to the player.