Can you use multiple remove events?

This is not true, if you do use your method your going to just make send data take longer for laggy players.

1 Like

What should I do then? I want to get in the habit of doing everything right, so want to learn all the best methods.

Yes, you can use a remote event in one script, and other scripts. as many as youd like.

I mean how should I properly have these “sanity checks” and be efficient as possible.

You can use as many remotes as needed, but I suggest you limit it to up to 10 per script in-case there are errors, 10 has a lower probability.

sanity checks??? What do you mean by that?

If you read the thread you will find out.

I did? im not sure still what he means by sanity checks? and how would that be applied to RemoteEvents?

Read that post by @Xueify it should explain it properly.

Sanity checks are just a method of verifying remote events since exploiters can fire them at any time. So lets say for example you have a remote event that allows the player to buy an item, before you grant them the item you check if they have enough money to purchase the item, instead of just giving them the item right away, so for every remote event you should find some way of verifying it. Also, ensure that all the data are the appropriate types so hackers can break the server, for example:

RemoteEvent.OnServerEvent:Connect(function(Player, ItemName)
    if typeof(ItemName) == "string" then

    end
end)

Using sanity checks effectively and efficiently can be tricky for people who are new to scripting.
Heres a quick example of an effective sanity check.

--LocalScript
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
RemoteEvent:FireServer("Hello World!") -- This will work because it has the correct argument
RemoteEvent:FireServer() -- This will not work because it has no argument

--ServerScript
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")

RemoteEvent.OnServerEvent:Connect(function(Player, Message)
	if Message and Message == "Hello World!" then -- Checks if there is a Message argument and if it is the correct argument
		print(Message)
	end
end)

We do this not just to prevent false Fires but also to prevent Errors from occurring.
If i did not check on the server if Message exists then the script would of error-ed.

More Information about Remote Functions and Events.

I suggest also understanding the Roblox Client-Server Model.

k got it thx. i didnt see that before.

so I have a remote event, on my server script I sent over ‘players’ in the argument. And in the local script I remove the local players backpack items.

If a hacker can change the argument sent in the remote event, how can I make sure his tools/items in backpack were removed?

Or is it only if the local script is sending data back to the server that you need to be worried?

The server should handle anything to do with giving or removing Items. If you want to remove a Players tools without having to worry about exploiting, you should have it all handled on the Server.

--LocalScript
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
RemoteEvent:FireServer()

--ServerScript
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")

RemoteEvent.OnServerEvent:Connect(function(Player) --default player argument (player who fired the event)
	local Tool = Player.Backpack:FindFirstChild("Gun") --Checks if the tool exists in the players Backpack
	
	if Tool then -- if the tool exists then remove it
		Tool:Destroy()
	end
end)