Is this an optimal way to protect the sphere from being piloted anywhere by exploiters?

I’m wondering how I can protect my damaging sphere that the player has network ownership over and a movement local script under from exploiters. Mostly everything is operated on the client for smooth gameplay, but I fear that exploiters can either tweak the script so that they can have no speed cap, accelerate extremely quickly, or turn quickly, or just move the sphere manually through injected code and teleport to everyone to win.

I was thinking of

  1. setting the network ownership to the server
  2. every 0.05 seconds a remote event will be fired to a server script that dictates all movement.

but I’m not sure how expensive this will be or if it will be playable at all. What should I do???

local camera = workspace.CurrentCamera
local movementInputs = script:WaitForChild("MovementInputs")

local forwardsInputAction = movementInputs:WaitForChild("Forwards")
local backwardsInputAction = movementInputs:WaitForChild("Backwards")

local rightInputAction = movementInputs:WaitForChild("Right")
local leftInputAction = movementInputs:WaitForChild("Left")

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local goingForwards = false
local goingBackwards = false
local goingLeftwards = false
local goingRightwards = false

local maxSpeed : number = player:GetAttribute("sphereMaxSpeed") -- Determines how fast the sphere can move.
--local damping = 1 -- Increases turning speed when under 1

local runService = game:GetService("RunService")

task.wait(10)

local sphereMovementConnection
sphereMovementConnection = runService.Heartbeat:Connect(function(deltaTime)
	local sphere : Part = script.SphereModel.Value
	if not sphere or not sphere.Parent then return end

	local additionalSpeed = humanoid.MoveDirection * 100 * deltaTime
	
	if maxSpeed ~= nil then
		if sphere.AssemblyLinearVelocity.Magnitude < maxSpeed then
			--sphere.AssemblyAngularVelocity *= damping
			sphere.AssemblyLinearVelocity += additionalSpeed
		else
			--sphere.AssemblyAngularVelocity *= damping
			sphere.AssemblyLinearVelocity = sphere.AssemblyLinearVelocity.Unit * maxSpeed
		end
	else
		repeat
			maxSpeed = player:GetAttribute("sphereMaxSpeed")
		until maxSpeed ~= nil
	end
end)

There’s also this I’m trying to fix:

Exploiters can simply disconnect the connection and then do whatever they want with the sphere. I would not recommend giving clients network ownership of kill parts.

Wait for server authority to come out of beta
Nothing else are effective

Hello!

Don’t set the network ownership to the server, it will ruin your game’s responsiveness, making your game really annoying to play.

If I’m understanding you right, the second method sounds sort of the same as the first, and will make your game much less responsive, since the server has to approve all movement.

Here are some good way to do this:

  1. Make an anti-cheat
    This is probably the easiest option, all you need to do is watch for if players are teleporting, going to fast, etc. and either kick them or correct there position. But anti-cheats aren’t perfect, since it could be hard to tell apart someone getting flung vs. a fly hack, lag vs. teleport hacks, etc., but it’s still really good.
  2. Client Prediction (not sure if what the actual name is)
    Another way is a much more difficult way, but it is very secure. How it works is you run your movement system simultaneously on the server and the client, by sending the input data from the client to the server, and due to network latency, the server will be slightly behind the client. Then, once the server receives those inputs, the server processes those inputs and tells the client where it should be. Once the client receives the server’s data, a bit after it sent the inputs, the client corrects itself if it’s off track, then this loop repeats again and again. This allows the server to stay in full control, but still have the client feel responsive. That’s a very basic explanation, so I recommend looking into it more if you want to use it. But it works, I’m using it for a racing game currently.

There are probably other ways out there, but these are some good ways to handle this.
Also, if you want to test how network latency affects your game, go to File > Studio Settings > Network > Incoming Replication Lag, and change that to test your game with network latency.

I hope I am able to help!

1 Like

is*

Server authority requires streaming and requires super good internet.
The best way is do what you can do and just sacrifice exploitability over gameplay smoothness, they are mostly gone anyway.

1 Like

Fair but then is there any way I can make my game work without removing its base functionality? Everything falls flat without the sphere not actually being able to kill people.

I tested the beta a month or two ago and it seems promising. If they can fix the rampant physics issues ESPECIALLY with different part shapes then I’ll see what I can do. But will server authority even be able to work with non-player characters? The player is basically turned into a sphere although I don’t destroy their character or anything, I just give them ownership over the sphere and then move it in their move direction.

1 Like

Yes they were both supposed to be employed with each other.

So you mean a server authority-esque system? Idk, I can try, but as yarik said I could just postpone dev until server authority is out of beta. This is cuz I’d also have to deal with regular players exploiting and with the amount of stuff I’d have to do for the sphere already I don’t think it’s really gonna work out :man_shrugging:t5:

What’s streaming? And does this mean players with high ping won’t be able to play at all without server authority going haywire? Why does it need such a good connection?

who is they? exploiters?

for now that sounds like the probable fix but with me also having to worry about players trying to survive the sphere exploiting do you think I should just put this on the backburner until server authority releases? With my somewhat limited time I think it’d just be more fun and manageable if I worked on a single player game, because most of the games I wanted to make are competitive but half of them would either take too much recourses / people to make or I just have exploiters to fear.

If it doesn’t need to be on the client, don’t put it on the client. Unless the sphere’s position must be different for everyone, put it all on the server.

This shouldn’t be the case because I’ve given the operator’s client ownership over the sphere, meaning that however they say it should move should reflect on all clients. But this also brings the issue that I noted in the post.

So why put it all on the client? This seems like an obvious server-sided situation.

I realized this before I made the post. The point of it was to ask if my proposed solution was optimal.

I believe this is what performance stats is for.

Waiting on this myself.. Got a dozen games in the chamber.

1 Like

I haven’t looked in to server authority much, but give it a try, it would probably work well. I think it uses a similar system to the client prediction I described, just with a lot more features. But the main benefit would be you won’t have to make the whole system from scratch.

If you are going down this route, I might look into UnreliableRemoteEvent’s
https://create.roblox.com/docs/reference/engine/classes/UnreliableRemoteEvent

They prioritize speed over reliability afaik.

Yeah I tried it and it’s really janky rn but they plan to fix it before it releases. Hopefully it’s out as soon as possible in a stable state.

I grouped these together since they’re basically the same thing but, when I tried making it, it was too complex. There are wayyyy too many factors and too much time required for me to be able to implement this. Not that I don’t want to, but for this specific game of mine it’s not gonna give me the bang for the buck that would make developing such an intricate system as this worth it.

Stuff like velocity spoofing and especially velocity changes.

The fact that they are unordered and ignore if a previous remote event is running sounds concerning. This’d probably lead to the new system being not only less responsive but also inaccurate.