Trying to set a variable's value from OnClientEvent

Hello! Before I talk about this, sorry if my formatting sucks. First post.
Anyways, I’m trying to use server based cooldowns to prevent use of no cooldown exploits.
My current method is a remote to read if there’s a cooldown in the cooldowns folder, where cooldowns are created via a remote from the client.

Here’s a block of code for the client.

local StrongPunchCooldown = false
table.insert(cooldowntable, StrongPunchCooldown)
function attackHeavy()
	local cd = checkcooldownsevent:FireServer("StrongPunchCooldown")
	if cd then return end
	if StrongPunchCooldown == true then print("got") return end
	cooldownevent:FireServer("StrongPunchCooldown", 5)
rs.Client.CheckForCooldownReturn.OnClientEvent:Connect(function(obj, val)
	local success, errormsg = pcall(function()
		cooldowntable[obj] = val
	if success then
		warn("Error while binding Cooldown. || "..errormsg)
	print(tostring(obj), val)
	return cooldowntable[obj]

Here’s CheckCooldowns for the server

game:GetService("ReplicatedStorage").CheckCooldowns.OnServerEvent:Connect(function(plr, cooldownname)
	local cds = plr.Cooldowns
	local clientevent = game:GetService("ReplicatedStorage").Client.CheckForCooldownReturn
	if cds:FindFirstChild(cooldownname) then
		clientevent:FireClient(plr, cooldownname, true)
	elseif not cds:FindFirstChild(cooldownname) then
		clientevent:FireClient(plr, cooldownname, false)

And lastly, here’s CreateCooldown from the server.

game:GetService("ReplicatedStorage").NewCooldown.OnServerEvent:Connect(function(plr, cooldownname, length)
	local cds = plr.Cooldowns
	local newcd ="BoolValue", cds)
	newcd.Name = cooldownname
	game:GetService("Debris"):AddItem(newcd, length)

Again, I’m very sorry if my formatting for this isn’t good. This is my first post and I barely remember anything from learning how to format.
Please suggest any ideas or concepts you think could work, thank you! :smile:

1 Like

You can’t send strings or numbers through RE’s, only globals.

local myString = "Yes"
local myNumber = 123

cooldownevent:FireServer(myString, myNumber)

Other than that, don’t understand what you really want here.

1 Like

I may be wrong, but it seems like the client tells the server to check if there’s a cooldown, and if there is no current cooldown then then It just sends the handling back to the client, which does nothing to prevent exploits. The exploiter could just copy and paste the attack script but remove the part where it tells the server to check for a cooldown.

1 Like

If you’re asking us to review your code, I believe this goes to #help-and-feedback:code-review, not Creations Feedback. If you are having problems, ask in #help-and-feedback:scripting-support instead. I’m not sure what you want to achieve in this topic.

@2jammers RemoteEvents accept any value or instance without using local or global variables, as even stated in the DevHub by demonstrating how you can send Vector3’s and BrickColors.

I dont believe he only wants code review as his values arent getting assigned…so there is script issue.

So yeah i believe belongs in script support.