Take away character control from the client

Is it possible to take away character control from the client and give it to the server? If so, could this be a way to stop certain exploits?

2 Likes

Well, handling these type of things on the server will cause a great increase in lag, and yes it can prevent some exploits like fly hacks speed hacks etc… A thing you can do is SetNetworkOwnership

What would I do? Set the NetworkOwnerShip of the players HumanoidRootPart to the server?

Set the character network ownership to nil, this will stop players from changing properties of their character, although it will cause a problem, a delay in their inputs, there are alot of tutorials for this tho!

1 Like

SetNetworkOwner can only be called on base parts (not models).

for _, Descendant in ipairs(Character:GetDescendants()) do
	if Descendant:IsA("BasePart") then Descendant:SetNetworkOwner() end
end

https://developer.roblox.com/en-us/api-reference/function/BasePart/SetNetworkOwner

2 Likes

How would I make the server the network owner of the character’s HumanoidRootPart?

The server isn’t an actual thing (instance) so you can not set the ownership to it.

What about setting the ownership to nil?

That is what I recommended in the start.

1 Like

I tried to do that but its not possible, I’m still able to change the humanoid properties from the client.

You can.

for _, v in pairs(character:GetDescendants()) do
	if v:IsA("BasePart") then
		v:SetNetworkOwner(nil)
	end
end

I’m still able to change the properties of the humanoid from the client.

1 Like

You can’t remove the humanoid properties away from the client, the client can not control character physics anymore by removing network ownership.

the client can still change and read properties they just will not replicate to the server or to anyone else

to remove access to an object the object needs to be placed in a server sided container (ServerScriptService or ServerStorage)

I changed NetworkOwnership like @msix29 said, and the changes from the client still update to the server.

can you give me an example of what replicates to the server?

Speed, and just moving the character around on the client by dragging it in studio.

If you mean like general movement and where the player reports to be - this has to happen. The player must have some authority over the character as they need to be able to move the character in some way.

There are still ways to prevent updated jump power and speed reporting to the server but you would have to (unrealistically) keep the player reporting their speed to the server directly and try make that reporting function as secure as possible - though this can still be deleted.

There may be better ways but with ROBLOX’s current set-up. Players still have the contents of most of the place locally with the ability to view what parts and local scripts exist. They can delete or add anything (if it’s not secure enough) to their local contents of the experience.

Are you sure you have set all the network ownership of the base parts in a character to nil?

and you are viewing from the server correct?

Yes

Code:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		for _, v in pairs(character:GetDescendants()) do
			if v:IsA("BasePart") then
				v:SetNetworkOwner(nil)
			end
		end
	end)
end)

Is this in a server script?

also you might wanna give a task.wait() before looping just so all the parts are ready