Skip to main content

Invoking Methods

Now, we can easily define custom methods and call them from our server proxy. Here's an example of how to do that:

warning

Custom methods are remote calls for multiple clients under the hood, so they cannot return values.

myEffect.ts
import { BaseEffect, VisualEffectDecorator } from "@rbxts/refx";

@VisualEffectDecorator
export class myEffect extends BaseEffect {
protected readonly DestroyOnEnd = false; // so our effect don't get destroyed instantly.
protected readonly MaxLifetime = 10;

public DoSomething(arg: number) { // our custom method
print(arg);
}
}

Let's create our effect and call our method from the server proxy:

somewhere.ts
import { myEffect } from "./myEffect";
import { Players } from "@rbxts/services";

const effect = new myEffect().Start(Players.GetPlayers());
effect.DoSomething(10);