Player.Character should be the correct character in Backpack LocalScripts

As a Roblox developer, it is currently too hard to get the character of a player on the client from a tool or any other script in their backpack.

Current Behavior: When a LocalScript needs a reference to the character and that LocalScript is somewhere in StarterPack, the script will run before the Character property of Player is set to nil or updated to the newest character. That means the script has to do something like this so that it does’t get the wrong character:

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

while not Character or not Character:IsDescendantOf(workspace) do
	Character = Player.CharacterAdded:Wait()
end

New Behavior: I think the behavior / order should be switched so that the property Player.Character is set to nil before the Backpack is populated with new scripts that also run before Player.Character is set to nil.

How will this help my game? This would be great when you rely on LocalScripts in Tools. When you have a LocalScript in a Tool, it often needs the Character to do local effects and check for descendants of the character. Having the character be the correct character for that Tool would create much less confusion and would make the debugging process much easier.

1 Like

This topic was automatically closed after 1 minute. New replies are no longer allowed.