Get player/character from backpack?

Making a script that changes the color of something everytime a tool is equipped, the problem is though I cannot get the player. the script doesn’t refer to any specific tool, instead checking if ANY tool is equipped.

local Tool = script.Parent

plr.Character.ChildAdded:Connect(function(tool)
	if tool:IsA("Tool") then
			for _, thing in ipairs(script.Parent:GetDescendants()) do
				if thing:IsA("SelectionBox") then 
		thing.Color3 = plr.TeamColor.Color
end
end
end
end)
end)

local player = Backpack.Parent
The parent will be the player because backpack is a child of player, and you can use player.Character to get the character.

1 Like

Try this

local Tool = script.Parent

plr.Character.ChildAdded:Connect(function(tool)
	if tool:FindFirstChildWhichIsA("Tool") then
		for _, thing in ipairs(script.Parent:GetDescendants()) do
			if thing:IsA("SelectionBox") then 
				thing.Color3 = plr.TeamColor.Color
			end
		end
	end
end)
end)

don’t know how I didn’t think of that, thanks.

1 Like

this didn’t work btw, it just broke it.

1 Like