local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
Cost = 5

function checkForChocolateMilk()
	local found = false
	for i, v in pairs(player.Backpack:GetChildren()) do
		if v.Name == "ChocolateMilk"
		then
			found = true
		end
	end
	for i, v in pairs(player.Character:GetChildren()) do
		if v.Name == "ChocolateMilk"
		then
			found = true
		end
	end
	
	if found == true
	then
		return true
	else
		return false
	end
end

script.Parent.MouseButton1Click:Connect(function()
	local leaderstats = player:FindFirstChild("leaderstats")
	if leaderstats
	then
		local Points = leaderstats:FindFirstChild("Points")
	end
	local Points = leaderstats:FindFirstChild("Points")
		if Points then
			local hasChocolateMilk = checkForChocolateMilk()
		if Points.Value >= Cost and hasChocolateMilk == false then
			Points.Value = Points.Value - Cost
			local ChocolateMilk = game.ServerStorage.ChocolateMilk:Clone()
			ChocolateMilk.Parent = player.Backpack
		end
		local found = false
		for i, v in pairs(player.Backpack:GetChildren()) do
		if v.Name == "ChocolateMilk"
				then
				found = true
			end
			if found == true
			then
				script.Parent.Parent.ChocolateMilkOwned.Visible = true
	    script.Parent.Parent.Roundify.ImageColor3 = Color3.fromRGB(255, 44, 47)
			
		    end
		end
	end
end)