Remote Function can be spammed from the client!

So here’s what I made on the server,

-- Server
local success, result = pcall(function()
    remoteFunc_WaitForLoad.OnServerInvoke = function(plr, isLoaded)
			if isLoaded == true then
					char:PivotTo(destination.CFrame*CFrame.new(math.random(-10,10), 0, math.random(-10,10)))
			end
	end
	remoteFunc_WaitForLoad:InvokeClient(plr, destination)
end)
if success then
				
else
  warn("Error:",result)
end

But as you can imagine if I make a while loop function, I get teleported after getting teleported once.

-- Client
LoadEvent.OnClientInvoke = function(objToLoad)
	local GameFile = workspace:WaitForChild("Game_Terrain")
	while true do 
		task.wait()
		LoadEvent:InvokeServer(true)
	end
end

But I don’t want that. I want to make it so if the server handles one clients Invoke it will depreciate itself or not work for that client until I can call the function later on the server.
‘‘The pCall() is in a function inside the server.’’

Remote Function can be spammed from the client!

Well it would be becuase you’re constantly setting the “isLoaded” argument as true
over and over again, so you would want to do something with your while loop…

image
image

1 Like

make a table, whenever the player fires a remote event add the player to the table with the current tick like so

event.OnServerInvoke = function(player)
     DebounceTable[player] = tick()
end)

Now whenever the event is called, subtract the current tick() from the one in the table to check how many seconds have passed. Sorta like a cooldown
Make sure to remove players from the table when they leave.

2 Likes

I mean the true on the isLoaded argument isn’t changing the program. Don’t get overwelmed by what I send with the InvokeServer function. When the server invokes the client my main purpose is to load that GameFile! because it gets put there prior to calling this function from the server so If I don’t waitForChild on the client. Sometimes slow Internet users, Slow Mobile users gets teleported in the location that I’ve given but because it hasn’t loaded into the clients machine; their characters falls into the void and dies. So after the waiting to see if the file has been found/loaded the client Invokes server “one time” but if I were a hacker and tried invoking this Remote Function from any other Local Script I could’ve done invoking the server in a while loop which may made the game kinda broken and unplayable for the normal users. So the while loop is there for tesing purposes to see if the server takes multiple requests. Which I am in no way seem to stop from happening. I just want them to use the function one time and then that Client’s server to client connection gets disconnected until It’s been recalled. Hope you understood! Much love <3

That’s a pretty good idea. Kinda a bruteforce way of doing it rather than having a prebuilt function for the Remote Function, but before I go with this plan, I will try using the remote event. Because I think there is a function that can be called once “ConnectOnce()” I guess something like this that I could use. It would be much better. Thanks anyways I’ll soon give an answer to what I’ve done when I do do so.

I found this method to be working perfectly. It’s better to just use Remote Event. On the server script you can just make something like this and after one iteration of this function it’ll stop for getting more request. Now if you want to make it so only players can join but ‘Join Once for prevent hackers from accessing’ then make a for loop and put this inside that for loop that holds players.

remoteFunc_WaitForLoad:Once(function(plr)

end)
remoteFunc_WaitForLoad:FireClient(plrFromForLoop)

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