When using remote events should the check that checks if the player can perform the action be in the server script or local script?
1 | workspace.Part.Touched:Connect( function (hit) |
2 | if hit.Parent.Name = = "Part" then |
3 | print ( "A" ) |
4 | game.ReplicatedStorage.RemoteEvent:FireServer() |
5 | end |
6 | end ) |
Should this be in the local script with fire server or a server script with onserverevent? Which is the most safest for no exploiters?
Touched
event on the client. If you really wanted to fire something with server scripts and server scripts only, use a BindableEvent
. These are for server-to-server communication or for client-to-client communication. These are not to make your game FE compatible.01 | local bindable = game.Workspace.Event |
02 | local part = game.Workspace.Part |
03 | local plrs = game:GetService "Players" |
04 |
05 | function getPlayerFromChar(char) |
06 | if plrs:GetPlayerFromCharacter(char) then |
07 | return plrs:GetPlayerFromCharacter(char) |
08 | end |
09 | end |
10 |
11 | bindable.Event:Connect( function () |
12 | -- code |
13 | end ) |
14 |
15 | part.Touched:Connect( function (part 2 ) |