so the output tells me the character is not a valid member of workspace. How do i fix this?

here is the section of the script:

if script.Parent then
	if not script.Parent:IsA("Script") or not script.Parent.Name == "StarterGear" then
		local debris = game:GetService("Debris")
		local backpack = script.Parent
		local player = backpack.Parent
		while player.Character == nil do wait() end
		local character = player.Character
		if character then
			while character:FindFirstChild("Humanoid") == nil do wait() end
			local hum = character:FindFirstChild("Humanoid")

10 comments

0

if character.Parent == game.Workspace then

0

doesnt work'

0

Don't wait for character on a loop. Wait for it using the CharacterAdded event.

0

Player.CharacterAdded:Wait() ^

0

have you defined the player? like

0

have you defined the player? like local.Humanoid = player or something?

0

@OnceLegend has a point

0

you should never assume that the Backpack's parent is always a Player

0

define the player outside the loop

0

so then the player should be gmae:getservice "players"?