This would be fixed just explaining you how remote events work, and explaining you properly. The documentation might be confusing at times.
Let's say, the client clicks on a button that makes the server create a block.
For this, you would use a Remote Event.
So, you create a remote event, called for example CreateBlock, inside the ReplicatedStorage. Why ReplicatedStorage, you might ask? Because it's a place both the client and server has access to. It's read only for clients, meaning no local scripts can change its contents.
To make this remote event work, you would have to define its behaviour in a server script or a local script. In this case, you define its behaviour in a server script since the server script is gonna do the work.
Note: when you define the behaviour of a remote event in a server script, ALWAYS the first parameter of the function is gonna be the player who fired the event. Be aware of that.
In the server script, then:
1 | local remoteEvent = game:GetService( 'ReplicatedStorage' ).CreateBlock |
4 | remoteEvent.OnServerEvent:Connect( function (player) |
5 | local part = Instance.new( 'Part' , workspace) |
Now, the remote event knows exactly what it must do: create a block. We defined it already in the server script.
Now, what is left, is to define WHEN it's gonna be fired from the client.
Let's say, then. that it fires every time the client presses 'F' key
1 | local remoteEvent = game:GetService( 'ReplicatedStorage' ).CreateBlock |
3 | game:GetService( 'UserInputService' ).InputBegan:Connect( function (input, gameProcessed) |
4 | if input.KeyCode = = Enum.KeyCode.F then |
5 | remoteEvent:FireServer() |
And that'd be it. Very simple, right? If you understand that, you would easily understand the rest of the documentation on remote events :)
Glad to help you brother, and remember, if this is useful for you, accept the answer!