How can I keep up with time change from client for the server changes?

I’m doing a gun system,and I’m having problems to store data which is the MOST crucial to deal with exploits for the system since I don’t want an exploiter shoot earlier,here’s my script and I want to tell that It always goes to 2nd Shoot to Kick Function no matter what I do.

--Entire thing is in a function.
if Type == "Attack" then

	if Player_Info_Table[Player] then

		if Type == "Attack" then

			if Value ~= "Shoot" and Value ~= "Melee" and Value ~= "None" and Value ~= "Cooldown" then

				return

			elseif Value == "Cooldown" and Value == "None" then

				Gun_Object_Holder[Current_Gun_Object_Key]["Status"][Type] = Value

			elseif (Value == "Melee" or Value == "Shoot") and Player_Info_Table[Player].Last_Attack then

				local Current_Time = time()

				local Time_Passed = Current_Time - Player_Info_Table[Player].Last_Attack

				if Time_Passed < Gun_Object_Holder[Current_Gun_Object_Key].__inherit["Fire Rate"] then

					Player:Kick("User Found With Exploits!")

				else

					Player_Info_Table[Player].Last_Attack = Current_Time

					Gun_Object_Holder[Current_Gun_Object_Key]["Status"][Type] = Value

				end

			end

		end

	else

		Player_Info_Table[Player] = {}

		Player_Info_Table[Player].Last_Attack = time()

		Gun_Object_Holder[Current_Gun_Object_Key]["Status"][Type] = Value

	end

else

	Gun_Object_Holder[Current_Gun_Object_Key]["Status"][Type] = Value

end

It always goes to

Player:Kick("User Found With Exploits!")

Section,My fire rate has value of 0.0923.

And even If I change value,It doesn’t change anything…

Any help is appreciated,I’m losing my mind on this one

just dont kick players when they fail a sanity check

also if ur handing a cooldown separately on the client u could just have the cooldown be an attribute that the server sets and the client reads to completely prevent it

I want to do it without attributes.

then use instance values :person_shrugging: (why not use attributes)

No,I want to do it from Neither of them,I want to do it via script.

It feels useless to use both Instance and Attribute values.

no its because attributes are the best solution for this. I use it for my ability systems. what’s stopping you from using attributes i dont understand

Actually wait,I will use them but Problem is NOW Bigger and It’s not even about this topic anymore.

Would it be ethical If I changed description and title?

first of all why r u using the same if condition twice, it isnt neccessary.

also it’s recommended to make a warning system (like this abnormality has to fire 5 times in short succession) instead of kicking the player immediately)

I know and forget it look at the question I have asked previously

yeah sure (############### for the character limit, ignore)

Is it the best way If I subbed

local SPF = 1 / workspace:GetRealPhysicsFPS()

it to my waiting time would it fix the solution?

Ur not gonna be able to sync the server and client completely so ur better off just not kicking the player

Also u could multiply the fire rate by 1.5 or smth in the sanity check so that there’s room for error

a side note: do not use time() for millisecond precision, the better way of comparing time would be either to use os.clock() or tick() especially if you’re trying to get millisecond precision, it could provide an error which maybe result in a condition bug, if not it’s still better to use those methods rather than time()

also regarding attributes and instances I understand why you’d rather not use them, especially if you’re entire framework relies on things being done through scripts and remote events having attributes randomly used for one replication use case isn’t the way to go in terms of consistency, have the client do its own cooldown checking and have a module script for constants that shares the fireRate value they both fetch from that, if someone is exploiting on the client they may bypass the cooldown but in the end you’re doing validation on the server and not registering the bypassed hit so only the client exploiting will see what its doing.

finally for structural purposes in your code, you should consider early return statements by inversing the conditionals statements, for example:

if not Player_Info_Table[Player] then
   return 
end
if Type ~= "Attack" then
   return
end

and so on, it avoids crazy nested conditionals and makes reading the code much better