Players.GetPlayerFromCharacter throws an error, didn't before

Reproduction Steps
Calling Players.GetPlayerFromCharacter on a non-character Instance throws an error.

Expected Behavior
Typically when calling Players.GetPlayerFromCharacter, it would return nil if a non-character is provided.

Actual Behavior
The function throws an error, potentially causing scripts to stop completely.

Workaround
The current workaround is to use a pcall on the function.

Issue Area: Engine
Issue Type: Performance
Impact: Very High
Frequency: Constantly
Date First Experienced: 2021-08-09 19:08:00 (-04:00)

15 Likes

Also having issues. All my proximity prompts, gameplay features, and combat systems relying on GetPlayerFromCharacter no longer works.

This essentially breaks half of my game since it expects nil to be returned.

6 Likes

This is actively occurring in Arsenal, causing the game to become more or less unplayable. This error is thrown whenever GetPlayerFromCharacter is called without a Model instance.

This occurs a lot when instance class checking isn’t provided (because previously this would simply return nil), which is pretty much every occurrence of this function being used ever. An extremely critical bug which really shouldn’t have occurred in the first place.

5 Likes

My sentry logs for my game have suddenly been throwing server and client errors. This is throughout older servers and new ones. This is definitely game.Players:GetPlayerFromCharacter() function which throws the same thing: Argument 1 is invalid: expected 'Model' instance type. I’m seeing this in studio as well – earlier today this problem did not exist.

This is a game breaking problem.

1 Like

Can confirm, this is also affecting Football Fusion and a variety of other games. The game is expecting a model as others have stated & returning nil error.

1 Like

Also having this issue. It should just return nil as usual instead of erroring as it used to. I hope this doesn’t become a permanent change.

1 Like

This change has been reverted. Game servers should resume the old behavior in the next few minutes; clients will have to be restarted for the revert to take effect. We’ll investigate how to roll this change out without causing this.

17 Likes

Just for clarification, do you mean this change (the method throwing the error) was an unintended side effect of a different change, or that it was a premature release of an upcoming intended breaking change in this method?
TL;DR should we expect this error to return in the future?

2 Likes

The method throwing an error is an unexpected effect of a change to provide more accurate type information in reflection. This error, or any others like it, should not recur going forward.

5 Likes