Jyrezo
(Jimmy)
March 3, 2023, 8:51pm
#1
Issue
On Player Join, items can’t be directly inserted into a Player’s Backpack, even after making use of WaitForChild .
Reproduction Steps
Open A Blank Baseplate
Create A Blank Script In ServerScriptService
Paste The Following Code Into The Script
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player: Player)
local Tool = Instance.new("Tool")
Tool.CanBeDropped = false
Tool.RequiresHandle = false
Tool.Parent = player.Backpack
end)
Run The Game
Workarounds
Place the Tool into StarterGear
Use ChildAdded events to wait for the Actual Backpack.
2 Likes
Focia19
(Focia19)
March 3, 2023, 9:09pm
#2
We’ve filed a ticket to our internal database, and we’ll follow up when we have an update.
Thanks for flagging!
2 Likes
This seems to be intended behavior. You need to wait for the character to load first.
Same applies to PlayerGui
, if CharacterAutoLoads
is false
.
Jyrezo
(Jimmy)
March 23, 2023, 6:22pm
#4
The problem mainly comes from the fact that there is a “fake” backpack that exists before the character loads in, and that causes problems. If they didn’t create the Backpack until the character is spawned, that would probably be better, and cause less confusion.
Well, even with that fake backpack, this functionality is the same as the PlayerGui
.
Osyris
(Osyris)
March 28, 2023, 7:24pm
#6
Just before firing the Player.CharacterAdded
event, the server will:
Destroy any existing Backpack
instances inside the Player
Create a new Backpack
instance and populate it using the contents of StarterPack
and StarterGear
.
In your original code, player.Backpack
is referring to the pre-existing Backpack
instance which is destroyed in the step 1.
Waiting for the new Backpack
with ChildAdded
will only solve this for the first time the player’s character is spawned.
Instead, you can listen for the Player.CharacterAdded
event like this:
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player: Player)
player.CharacterAdded:Connect(function(character: Model)
local Tool = Instance.new("Tool")
Tool.CanBeDropped = false
Tool.RequiresHandle = false
Tool.Parent = player.Backpack
end)
end)
4 Likes
system
(system)
Closed
April 11, 2023, 7:24pm
#7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.