Detecting if the player touched a client-sided part on the server

In my game, there are supposed to be various different moving objects that exist only on the client. Each client has a different set of moving objects. If a player touches one of these moving objects, something is supposed to happen to their character. The problem however, is that when a player touches one of the objects that are on their client, I want the server to detect if they touched one of these parts, so that way, the client can’t use exploits to claim that they touched a certain moving part, even though they didn’t touch one at all. Another problem that I am likely to encounter while trying to do this is that if the player touches multiple different objects while they are lagging, the server might not even register the touch at all, because of this lag. How would I accomplish something like this? I don’t think it’s that difficult to detect if a player touched one of these objects on the server; I can write an algorithm that can do that, but none of this will fix the problems with latency, and lag.

Also, when I say lag, I am referring to network lag. Ie: the player’s movements are delayed on the server, due to how high their latency is, or the player occasionally appears to be walking, but their character isn’t moving, and when their player starts moving, it appears to teleport to their current location.

2 Likes

How about Remote Events?
NOTE: I havent tried this yet but u could use this as an example

LOCAL SIDE:

local remote = game.ReplicatedStorage.RemoteEvent
--assuming u have the part defined
part.Touched:Connect(function(hit)
  if hit.Parent:FindFirstChildWhichIsA("Humanoid") then
local char = hit.Parent
    remote:FireServer(char)
    end
end)

NOTE: I havent tried this yet but u could use it as an example
SERVER SIDE:

local remote = game.ReplicatedStorage.RemoteEvent

remote.OnServerEvent:Connect(function(plr, char)
--code here
end)

Edit: You could use workspace:GetPartsInPart(part,params) instead of .Touched event

1 Like

This won’t work, because an exploiter could just fire that remote event any time they want, as many times as they wanted to make the server think that they touched whatever object the exploiter desired, even if they didn’t actually touch it.

1 Like

Simply put there is no reliable way for a client only part to be protected from exploits, instead try making a server part but make it visible for only a specific client.

1 Like

Is your game single player or multi player? And does your game have a global leaderboard

1 Like

So, you are saying that what I am trying to accomplish, most likely won’t work?

Multiplayer.

Note: I can’t answer every single question that I am asked, because I don’t want to leak what the game is being about, but I have worded my question such that nobody will know what the game is.

1 Like

What are the functions of the client side part?

1 Like

I mean other than accepting exploitability if you have client only parts or just making a server part and make it visible for only one specific client I wouldn’t know a way cause everything on the clientside can be accessed by the client.

why wouldnt you want to do this btw

OP is worried about server-client latency.

There would be no possible way to communicate between server and client without the use of RemoteEvents.

How about adding a true / false variable and if it is false kick the player and if its true it do nothing to player

note: dont think this will work cuz idk how to make local script and server script share variables

global variables wont work due to serious issues on the client.

I would use module script with functions. Require modulescript then destroy it. The functions of module script will still work even if it is destroyed because I already required it

1 Like

You need a way of syncing the parts position with the server. Then the server can check if a touch is valid based on that position, accounting for a player’s ping.

1 Like

The client reacts faster than the server, but the server isnt that slow. The server will definitely register the touch, it may be delayed compared to the client though.

But the client can also sometimes be slower than the server.

Touch events should be done on the server, client-side will be abused by exploiters.

Don’t always worry about latency, doing stuff server-side is necessary. Many games have killbricks that are all completely server-sided.

1 Like

Theres no reliable way to do hit detection on the client without there being vulnerability, maybe make the part on the server but only visible on one client? < add the touched event on the server too

2 Likes

Only time needs tobe synced, distance is calculated.

Can’t you also just create the part on the server so both the client and server knows about it, then tween the parts on the client for optimization. And set up the touch event on the server??

I think I know what you’re talking about, Touched events have bad detection for both client/server when there are moving objects.

If you have some sort of event to check this, use a distance check for better detection. Then you can easily use a server-side sanity check to make sure the distance is correct.

If you are doing this in some sort of loop though, then I think you should do this completely server-sided with a distance check for how far all players are from all the moving objects.

Magnitude is actually more of an optimal strategy for loops and is normally faster, I believe from a conducted experiment.

Roblox bans/terminates exploiters who modify the client

1 Like