Simulating randomness from client to server

Heyo!

Currently, I am trying to verify client mouse randomness to the server. The issue is the client can/may return an original mouse position and not the randomized one. If this occur in my gun system, the server will just receive the randomness regardless of value and get a perfect accuracy.

Why I didn’t send mouse location to the server instead? I want to create a smooth gun system in client and server, which use a raycast on both side.

Anyone got idea how to verify the client mouse randomness in the server?

Why are you involving the client then? Just generate a random mouse location in the server

1 Like

I’m trying to do it on the client first. If I handle it on the server alone, there will be quite delay and make the system seems less responsive

I don’t really get the use case here, could you provide more context?

My idea is double raycasting, both from client and server side. The client can handle the first,fake visual raycast and send the mouse randomness to server so the server can handle the damaging/other security stuff. If I use randomness on the both side, the mouse will be out of sync most of the time.

You can use the Random Object to have predictable randomness. As long as both the client and the server start with the same seed, and that you use :NextNumber() (or the other methods) the same amount of time on the client and server, the random values will be identical.

I have used this in the past and it works wonders, can be kind of niche but it’s very useful

How would I use this? Like creating a new seed first time the tool is equipped or something?

local seed = --random number, either create a random number with math.random and send it to the client or use the jobid of the server to get a random value 

local RandomObject = Random.new(seed)

local function GetRandomValue()
   --return RandomObject:NextUnitVector() Whatever function is best for your use case
   return RandomObject:NextNumber()
end

How the random object works is that, when you get a random number from the random object, it will go to the next “random” number, but the series of random numbers you get is the same for every random object with the same seed

Basically, it’s a pseudo random algorithm that returns a series of numbers that seem random, it’s not true randomness

1 Like

image

This is a module script I made, all it’s used for is to determine the color of the player’s ball, when they are balled. It uses the JobId to get a random seed, and has a salt parameter which is basically the UserId as to make it so different players get different colors.
The module is made to return only 1 random number though, for your use case it would be better to return the RandomObject instead of a random integer directly

It doesn’t have to be this complex, but it would avoid having to send the seed to the player. You would only need to use the JobId for the seed, every player on the server would get the same random sequence, but the sequence would change depending on the server

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.