so this is from the receiving side in a script in starter character scripts:
1 | game.ReplicatedStorage.jump.OnServerEvent:Connect( function (me, mouse) |
2 | mouse.KeyUp:Connect( function (key) |
3 | if key = = "Space" then |
4 | holding = false |
5 | end |
6 | end ) |
7 | end ) |
and this is the sending side in a local script also in starter character scripts:
1 | local mouse = game.Players.LocalPlayer:GetMouse() |
2 | game.ReplicatedStorage.jump:FireServer(mouse) |
and there is a remote event named jump in replecated storage when i print mouse on local script it says instance (good) but when i print mouse in script it says nil (bad) why is this happening?
The API for GetMouse()
states: "This item must be used in a LocalScript to work as expected online."
I think you would be better off using UserInputService on the client (LocalScript) to get the player's input, and then fire the remote event. Something like this:
1 | local UserInputService = game:GetService( "UserInputService" ) |
2 | local remoteEvent = game:GetService( "ReplicatedStorage" ).jump |
3 |
4 | UserInputService.InputEnded:Connect( function (input) |
5 | if input.KeyCode = = Enum.KeyCode.Space then |
6 | jump:FireServer() |
7 | end |
8 | end ) |
I recommend you read the documentation on UserInputService
if you don't fully understand.
Hope this helped, good luck!