Something very fast on the Server like RenderStepped?

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.."!")

https://gyazo.com/1b0545fd42fab90f3fee7c0aa4a561c5

1 Like

Just use welds. Physics engine is always best for this kind of stuff and has the added benefits of being automatically replicated accurately.

If I would weld, then to which part? Welding to the HumanoidRootPart would glue him to me so how do you imagine doing that?

Use BodyPosition thing. Create it in target’s humanoidrootpart and set BodyPosition.Position to player’s humanoidrootpart position (not CFrame)

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.

I never worked with BodyPosition thing before so I actuall don’t really know how to do this.

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.

1 Like

First you should use a weld. Or use raw .CFrame

You could have it both on the client and the server.
Teleport on .Stepped on the server

Also do you should do .Stepped on the person who is detained locally.

You should never use .RenderStepped for physics, only for rendering visuals.

So you want me to do it that it looks smooth via the client but on the Server its unsmooth?

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.

Just use a weld

Only WeldConstraints do this, use a regular weld instead and set the player in the position before you weld it.

--++++++++++++++++++++++++++//<<>>\\++++++++++++++++++++++++++--
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.

WeldConstraints actually work. Maybe you messed that up? Now it is just very weird and glitchy…
Place1 - Roblox Studio (gyazo.com)

EDIT: Only the person being detained can walk and you walk sometimes very slow idk why.
Using a regular weld just puts him into me.

Solution:
Weldconstraint and set the characters state to death, then cancollide him false and boom.
That is working.