R
roblox-ts•2mo ago
Lukas :3

getComponents returns nothing even when it should

hello I have script like this
if (this.socketAddress.address === 0) {
const components = Dependency<Components>();
const parent = this.instance.Parent?.Parent;
if (parent) {
wait(1); // fix this later
const assemblyRoot = components.getComponents<GetAssemblyUID>(parent);
print("list of assemblyRoots :3", assemblyRoot);
if (assemblyRoot.size() !== 0) {
this.socketAddress.address = assemblyRoot[0].getAssemblyUID();
} else {
warn("address set to automatic, but no root found on instance ", parent);
}
}
if (this.socketAddress.address === 0) {
const components = Dependency<Components>();
const parent = this.instance.Parent?.Parent;
if (parent) {
wait(1); // fix this later
const assemblyRoot = components.getComponents<GetAssemblyUID>(parent);
print("list of assemblyRoots :3", assemblyRoot);
if (assemblyRoot.size() !== 0) {
this.socketAddress.address = assemblyRoot[0].getAssemblyUID();
} else {
warn("address set to automatic, but no root found on instance ", parent);
}
}
for some reason it can't find that method in component, when literally there should be 100% chance to be there.
@Component({
tag: "model:Engine",
})
export class Engine extends BaseComponent<{}, EngineModel> implements GetAssemblyUID, OnStart {
@Component({
tag: "model:Engine",
})
export class Engine extends BaseComponent<{}, EngineModel> implements GetAssemblyUID, OnStart {
does anyone know why?
4 Replies
Lukas :3
Lukas :3OP•2mo ago
getAssemblyUID(): number {
print("got called :3");
return 128 as number;
///return tonumber(tostring(this.parent.getAssemblyUID()) + "1") as number;
}
getAssemblyUID(): number {
print("got called :3");
return 128 as number;
///return tonumber(tostring(this.parent.getAssemblyUID()) + "1") as number;
}
it's clearly there the interesting thing is that this is not the only component that uses that, but with that second one it's all alright....
@Component({ tag: "model:Airship" })
export class Airship extends BaseComponent<IAttributes, AirshipModel> implements OnStart, GetAssemblyUID {
// target speed that is set to be delivered
private targetSpeed: number = 0;
private targetRotationSpeed: number = 0;
//acceleration of rotation and speed
public rotationSpeedAcceleration: number = 2;
public speedAccelaration: number = 2;
// currect rotation and speed
// also might remove later? - currect speed
private speed: number = 0;
// currect rotation speed
private rotationSpeed: number = 0;
// rotation and speed limits
// might remove later?
public maxSpeed: number = 60;
public maxRotationSpeed: number = 200;
// maximum weight of payload that airship can carry
private maxPayloadWeight: number = 2000;
//Gauges
private speedGaugeComponent?: GaugeComponent; // not defined
private gasGaugeComponent?: GaugeComponent; // not defined
private heightGaugeComponent?: GaugeComponent; // not defined
// Rudders
private rotationRudder?: RudderComponent;
private assemblyUID!: number;
// Engine
private engine?: Engine;

// this initializes update so physics is running, it also sets correct payload hold and connects needed components
onStart(): void {
this.update();
this.setPayloadCapacity();
this.assemblyUID = new UID(this.attributes.OwnerID).uid;
this.connectComponents();
}
getAssemblyUID(): number {
return this.assemblyUID;
}
@Component({ tag: "model:Airship" })
export class Airship extends BaseComponent<IAttributes, AirshipModel> implements OnStart, GetAssemblyUID {
// target speed that is set to be delivered
private targetSpeed: number = 0;
private targetRotationSpeed: number = 0;
//acceleration of rotation and speed
public rotationSpeedAcceleration: number = 2;
public speedAccelaration: number = 2;
// currect rotation and speed
// also might remove later? - currect speed
private speed: number = 0;
// currect rotation speed
private rotationSpeed: number = 0;
// rotation and speed limits
// might remove later?
public maxSpeed: number = 60;
public maxRotationSpeed: number = 200;
// maximum weight of payload that airship can carry
private maxPayloadWeight: number = 2000;
//Gauges
private speedGaugeComponent?: GaugeComponent; // not defined
private gasGaugeComponent?: GaugeComponent; // not defined
private heightGaugeComponent?: GaugeComponent; // not defined
// Rudders
private rotationRudder?: RudderComponent;
private assemblyUID!: number;
// Engine
private engine?: Engine;

// this initializes update so physics is running, it also sets correct payload hold and connects needed components
onStart(): void {
this.update();
this.setPayloadCapacity();
this.assemblyUID = new UID(this.attributes.OwnerID).uid;
this.connectComponents();
}
getAssemblyUID(): number {
return this.assemblyUID;
}
i though it could be because that component is not loaded yet, that's why i gave it task.wait(), but no matter the time i wait it still outputs it
Tester
Tester•2mo ago
I think it's because they didn't load or smth Or can you actually task.delay it instead of task.wait()?
Lukas :3
Lukas :3OP•2mo ago
the reason was cuz script crashed
Tester
Tester•2mo ago
🫠

Did you find this page helpful?