RemoteEvent make countdown for the player called the event [Stop Client Exploiting]

Depending on what the countdown is used for, I don’t really see the issue with handling it on the client, if it isn’t going to cause immense harm by it being skipped than accounting for exploits in that regard isn’t entirely necessary.

As for handling the countdown on the server, you should be using RemoteFunctions as opposed to RemoteEvents so that the client can receive a returned value upon the countdowns completion that essentially tells it to proceed with whatever code was waiting.

1 Like

Thank you I hadn’t thought about using the RemoteFunction but I have another question, how can I know the time it takes for such a player.

I’m not entirely sure what you mean, could you elaborate?

Okay, I’m going to try to do it in detail. So I have a local script which when you press a key on your keyboard call the RemoteEvent, currently the countdown is on the localscript so an exploit could easily bypass it and I would like to set the countdown on the server script for completely stop the exploiter

Sry if my english is bad

Alright, well, to put it simply, you could track the time a players countdown has through a variable in the RemoteFunction “processing function”, or you could store it in an external value somewhere and view it’s value at any time.

I’m not sure I understood that, it may have been a while since I used the RemoteFunction and Event. Could you explain it in more detail?

Imagine you have a function that reads like this:

script.Function.OnServerInvoke = function(Time)
   repeat wait(1) Time = Time - 1 until Time <= 0
   return
end)

“Time” in this scenario, before the repeat loop, would be the total time a players countdown has. You could transfer this into a Number/IntValue or you could send it elsewhere in the script upon the functions inception.

Huh, sorry I’m not sure I understand, I have to create an intValue in the player to keep track of the time? Otherwise with a documentation link or a roblox post that could help me

You can either create an IntValue to store it externally, or you can process the “Time” variable elsewhere outside of the OnServerInvoke function.

i.e:

script.Function.OnServerInvoke = function(Player, Time)
   local IntValue = Instance.new("IntValue")
   IntValue.Value = Time
   IntValue.Name = Player.Name.."Countdown"
   repeat wait(1) Time = Time - 1 until Time <= 0
   return
end)

So imagine that I call your event with the temp “30” what will happen?

I can’t understand the variable time

   repeat wait(1) Time = Time - 1 until Time <= 0

That line of code simply subtracts a second from the “Time” variable until “Time” reaches 0.

Okay, and after it return it ? So how i can detect if is the time for the player

The Player is automatically sent as the first argument of RemoteEvents and RemoteFunctions.

Okay, well I appreciate that I’m just doing an if = 0 with the return of the Function.
But There is one thing that I do not understand, if the event is called by several players in my short time or almost it will not be a problem?

There will be no problems no matter how many players invoke the RemoteFunction because calling an Event creates a new thread in the script - it wouldn’t pause anything except things waiting on the countdown which you would want anyway.

@TerryMichaelBrunk Okay ! thx i will try it and give you return if is not working

U make a fail the end of Remotefunction don’t need “)”

@TerryMichaelBrunk i try to make this but just give me error.
image

script.Function.OnServerInvoke = function(Player, Time)
   local IntValue = Instance.new("IntValue")
   IntValue.Value = Time
   IntValue.Name = Player.Name.."Countdown"
   repeat wait(1) Time = Time - 1 until Time <= 0
   return
end

game.ReplicatedStorage.callMeHeh.OnServerEvent:Connect(function(plr)
 	if game.Players[plr.Name]:FindFirstChild(plr.Name.."Countdown").Value == 0 then
	print("Time is 0");
	end
	script.Function:InvokeServer(30)
end)

Wait im dump the countdown d’ont existe yes ?

image

You are trying to identify the value without setting it’s parent - something I left out of the original code since I was unaware with how you were handling the values.

script.Function.OnServerInvoke = function(Player, Time)
   if not Player:FindFirstChild("Countdown") then
      local IntValue = Instance.new("IntValue")
      IntValue.Value = Time
      IntValue.Name = "Countdown"
      IntValue.Parent = Player
   end
   repeat wait(1) Time = Time - 1 until Time <= 0
   return
end

game.ReplicatedStorage.callMeHeh.OnServerEvent:Connect(function(plr)
 	if game.Players[plr.Name]:FindFirstChild("Countdown").Value == 0 then
	print("Time is 0");
	end
	script.Function:InvokeServer(30)
end)

Try this instead.

1 Like

@TerryMichaelBrunk actually not working :confused: I edited for create the value in a custom Floder but with that or without is not woking
image

script.Function:Invoke(1)
script.Function.OnServerInvoke = function(Player, Time)
   if not Player:FindFirstChild("Countdown") then
      local IntValue = Instance.new("IntValue")
      IntValue.Value = Time
      IntValue.Name = "Countdown"
      IntValue.Parent = Player.DataStore
   end
   repeat wait(1) Time = Time - 1 until Time <= 0
   return
end

game.ReplicatedStorage.callMeHeh.OnServerEvent:Connect(function(plr)
 	if game.Players[plr.Name].DataStore:FindFirstChild("Countdown").Value == 0 then
	print("Time is 0");
	end
	script.Function:InvokeServer(30)
end)

And i changed RemoteFunction For binable becose studio don’t let me execute RemoteFunction in server script

Finally i found alternative and patch this problem with other problem