roblox-aurora / rbx-net

Advanced multi-language networking framework for Roblox
https://rbxnet.australis.dev/
MIT License
94 stars 12 forks source link

Why is my Remotes.Server.OnFunction complaining about Argument of type 'string' is not assignable to parameter of type 'never'? #93

Closed dev-syn closed 9 months ago

dev-syn commented 10 months ago

Remotes.ts:

import Net, { Definitions } from '@rbxts/net';
import type { SerializedCharacter } from '../types/Serialized/SerializedCharacter';

const Remotes = Net.CreateDefinitions({
    GetCharacters: Definitions.ServerFunction<(player: Player) => SerializedCharacter[]>()
});

export = Remotes;

main.server.ts:

import Remotes from 'shared/Remotes';
import type { SerializedCharacter } from '../types/Serialized/SerializedCharacter';

Remotes.Server.OnFunction('GetCharacters',(player: Player) => {
    return [];
});

image_2023-12-10_070241897

image_2023-12-10_070342989

dev-syn commented 10 months ago

Though I am able to get it to work with the Remotes.Server.Get()

import Remotes from 'shared/Remotes';
import type { SerializedCharacter } from '../types/Serialized/SerializedCharacter';

Remotes.Server.Get('GetCharacters').SetCallback((player: Player) => {
    return [];
});

Remotes.Server.OnFunction('GetCharacters',(player: Player) => {
    return [];
});

image_2023-12-10_073404699

OverHash commented 9 months ago

I wasn't aware that Remotes.Server was still around. Using .Get is the recommended way to do things.

dev-syn commented 9 months ago

I wasn't aware that Remotes.Server was still around. Using .Get is the recommended way to do things.

Ok I only was lead to OnFunction because Remotes.Server.Get() was pointing to Remotes.Server.OnFunction() as a better alternative but I will just use Get then.