How can I changed the datamodel Lantern to true when player has it in their backpack?

I have made a tool datastore but the issue I am running into is how can I change the bool value [Lantern] datamodel to true if a player has a lantern in their inventory?? Here is a screenshot of where the datamodel is.
Screen Shot 2023-03-05 at 8.11.37 AM

game:GetService("Players").PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Backpack = Player.Backpack
		if Backpack:FindFirstChild("Lantern") then
			Player.OwnedTools.Lantern.Value = true
		end
		Backpack.ChildAdded:Connect(function(Child)
			if Child:IsA("Tool") then
				if Child.Name == "Lantern" then
					Player.OwnedTools.Lantern.Value = true
				end
			end
		end)
	end)
end)
1 Like

Thanks for your help!! This solution worked!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.