roblox-ts / services

A module that exports common Roblox services.
9 stars 11 forks source link

Add Player class in index #21

Closed FelipeMartinsFrudeli closed 9 months ago

FelipeMartinsFrudeli commented 11 months ago

The class will able to receive Player type in params

. .

Example:

main.client.ts

import PlayerSetup from "./playerSetup";
import { Players } from "@rbxts/services";

const playerSetup = new PlayerSetup(Players.LocalPlayer)

playerSetup.ts

import { Player } from "@rbxts/services";

export default class PlayerSetup {

    constructor(player: Player) {
        print(player.Name)
    }
}
wad4444 commented 11 months ago

Looks weird to me

rimuy commented 11 months ago

You're already able to use the Player type in roblox-ts. The change made in this PR declares a Player constant that does not exist in roblox, which makes it able to be imported and used in TypeScript as a constant but in practice it's just nil. That class example already compiles and works without the need of importing the type:

https://roblox-ts.com/playground/#code/KYDwDg9gTgLgBAE2AMwIYFcA28DGnUDOBcACvgJ7BQDKwM6YcA3gLABQ7cXcOEAdgRhR0OGNAAUYClQBcpaVACUzTtzVgoASz4xJCgHQA5VAFtgi1VwC+7K0A